From 90790780829892f58bcdfe138a409d8268938f22 Mon Sep 17 00:00:00 2001 From: alan910127 <70696274+alan910127@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:00:46 +0800 Subject: [PATCH 1/2] fix: keeps commenting on every push --- src/comment.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/comment.ts b/src/comment.ts index 81a580a8..068b7601 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -5,7 +5,7 @@ import type { VersionType, } from '@changesets/types' import type { Gitlab } from '@gitbeaker/core' -import type { MergeRequestDiffSchema } from '@gitbeaker/rest' +import type { MergeRequestChangesSchema } from '@gitbeaker/rest' import { captureException } from '@sentry/node' import { humanId } from 'human-id' import { markdownTable } from 'markdown-table' @@ -132,10 +132,10 @@ const getNoteInfo = (api: Gitlab, mrIid: number | string) => ) const hasChangesetBeenAdded = async ( - allDiffsPromise: Promise, + changedFilesPromise: Promise, ) => { - const allDiffs = await allDiffsPromise - return allDiffs.some(file => { + const changedFiles = await changedFilesPromise + return changedFiles.changes.some(file => { return ( file.new_file && /^\.changeset\/.+\.md$/.test(file.new_path) && @@ -169,14 +169,19 @@ export const comment = async () => { let errFromFetchingChangedFiles = '' try { const latestCommitSha = CI_MERGE_REQUEST_SOURCE_BRANCH_SHA - const allDiffsPromise = api.MergeRequests.allDiffs(context.projectId, mrIid) + const changedFilesPromise = api.MergeRequests.showChanges( + context.projectId, + mrIid, + ) const [noteInfo, hasChangeset, { changedPackages, releasePlan }] = await Promise.all([ getNoteInfo(api, mrIid), - hasChangesetBeenAdded(allDiffsPromise), + hasChangesetBeenAdded(changedFilesPromise), getChangedPackages({ - changedFiles: allDiffsPromise.then(x => x.map(x => x.new_path)), + changedFiles: changedFilesPromise.then(x => + x.changes.map(x => x.new_path), + ), api, }).catch((err: unknown) => { if (err instanceof ValidationError) { From 2d7773fb0c546599bb8a6bfa6d9d05479962d2be Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 5 Dec 2023 01:10:26 +0800 Subject: [PATCH 2/2] Create spicy-buses-wonder.md --- .changeset/spicy-buses-wonder.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/spicy-buses-wonder.md diff --git a/.changeset/spicy-buses-wonder.md b/.changeset/spicy-buses-wonder.md new file mode 100644 index 00000000..eb25b63d --- /dev/null +++ b/.changeset/spicy-buses-wonder.md @@ -0,0 +1,6 @@ +--- +"changesets-gitlab": patch +--- + +fix: keeps commenting on every push ~ +- close #145, revert #143