From fd4faaccaa7b2d1f0282ee7db99f7f6dd122ddb2 Mon Sep 17 00:00:00 2001 From: alan910127 <70696274+alan910127@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:10:11 +0800 Subject: [PATCH 1/2] fix: deprecation warning in the `comment` command --- src/comment.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/comment.ts b/src/comment.ts index 52df9a10..a34108b7 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -4,7 +4,8 @@ import type { ReleasePlan, VersionType, } from '@changesets/types' -import type { Gitlab, MergeRequests } from '@gitbeaker/core' +import type { Gitlab } from '@gitbeaker/core' +import type { MergeRequestDiffSchema } from '@gitbeaker/rest' import { captureException } from '@sentry/node' import { humanId } from 'human-id' import { markdownTable } from 'markdown-table' @@ -131,12 +132,10 @@ const getNoteInfo = (api: Gitlab, mrIid: number | string) => ) const hasChangesetBeenAdded = async ( - changedFilesPromise: ReturnType, + allDiffsPromise: Promise, ) => { - const changedFiles = await changedFilesPromise - const changes = - 'changes' in changedFiles ? changedFiles.changes : changedFiles.data.changes - return changes.some(file => { + const allDiffs = await allDiffsPromise + return allDiffs.some(file => { return ( file.new_file && /^\.changeset\/.+\.md$/.test(file.new_path) && @@ -169,19 +168,14 @@ export const comment = async () => { let errFromFetchingChangedFiles = '' try { const latestCommitSha = CI_MERGE_REQUEST_SOURCE_BRANCH_SHA - const changedFilesPromise = api.MergeRequests.showChanges( - context.projectId, - mrIid, - ) + const allDiffsPromise = api.MergeRequests.allDiffs(context.projectId, mrIid) const [noteInfo, hasChangeset, { changedPackages, releasePlan }] = await Promise.all([ getNoteInfo(api, mrIid), - hasChangesetBeenAdded(changedFilesPromise), + hasChangesetBeenAdded(allDiffsPromise), getChangedPackages({ - changedFiles: changedFilesPromise.then(x => - x.changes.map(x => x.new_path), - ), + changedFiles: allDiffsPromise.then(x => x.map(x => x.new_path)), api, }).catch((err: unknown) => { if (err instanceof ValidationError) { From 86df78dba28eee6ebfa702f6310d414170be752e Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 23 Nov 2023 16:14:38 +0800 Subject: [PATCH 2/2] Create five-ravens-worry.md --- .changeset/five-ravens-worry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/five-ravens-worry.md diff --git a/.changeset/five-ravens-worry.md b/.changeset/five-ravens-worry.md new file mode 100644 index 00000000..3230a93a --- /dev/null +++ b/.changeset/five-ravens-worry.md @@ -0,0 +1,5 @@ +--- +"changesets-gitlab": patch +--- + +fix: deprecation warning in the `comment` command