diff --git a/.changeset/get-changed-files-warning.md b/.changeset/get-changed-files-warning.md new file mode 100644 index 00000000..2b17d309 --- /dev/null +++ b/.changeset/get-changed-files-warning.md @@ -0,0 +1,5 @@ +--- +"get-changed-files": patch +--- + +Fix a crash (`core.warn is not a function`) on push events when the pushed commit is associated with more than one open PR, as happens with stacked PRs. The github-script `core` API method is `core.warning`, not `core.warn`. diff --git a/actions/get-changed-files/get-changed-files.test.ts b/actions/get-changed-files/get-changed-files.test.ts index 4f9329c2..73feeadc 100644 --- a/actions/get-changed-files/get-changed-files.test.ts +++ b/actions/get-changed-files/get-changed-files.test.ts @@ -8,7 +8,7 @@ type PullRequestSummary = { }; const makeCore = () => ({ - warn: vi.fn(), + warning: vi.fn(), info: vi.fn(), setFailed: vi.fn(), setOutput: vi.fn(), @@ -161,7 +161,7 @@ describe("getChangedFiles", () => { prLookupArgs: github.rest.repos.listPullRequestsAssociatedWithCommit.mock .calls[0]?.[0], - warnCalls: core.warn.mock.calls.length, + warnCalls: core.warning.mock.calls.length, compareArgs: github.rest.repos.compareCommits.mock.calls[0]?.[0], }).toEqual({ prLookupArgs: { diff --git a/actions/get-changed-files/index.ts b/actions/get-changed-files/index.ts index 26212650..d199c066 100644 --- a/actions/get-changed-files/index.ts +++ b/actions/get-changed-files/index.ts @@ -54,7 +54,7 @@ type ContextLike = { }; type CoreLike = { - warn: (message: string) => void; + warning: (message: string) => void; info: (message: string) => void; setFailed: (message: string) => void; setOutput: (name: string, value: string) => void; @@ -113,7 +113,7 @@ const getBaseAndHead = async ( `Could not determine base ref for '${context.eventName}' event.`, ); } - core.warn( + core.warning( `Found ${pullRequests.length} PRs with the pushed commit (${afterSha}). ` + `Proceeding on a hunch with the first one (#${first.number} - ${first.title})`, );