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 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) {