Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-ravens-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"changesets-gitlab": patch
---

fix: deprecation warning in the `comment` command
22 changes: 8 additions & 14 deletions src/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -131,12 +132,10 @@ const getNoteInfo = (api: Gitlab, mrIid: number | string) =>
)

const hasChangesetBeenAdded = async (
changedFilesPromise: ReturnType<MergeRequests['showChanges']>,
allDiffsPromise: Promise<MergeRequestDiffSchema[]>,
) => {
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) &&
Expand Down Expand Up @@ -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) {
Expand Down