From 23e3e4516165c6b2ecf53163c17ef51700924ff9 Mon Sep 17 00:00:00 2001 From: Braden Rich Date: Thu, 11 Jun 2026 12:58:55 -0400 Subject: [PATCH 1/3] Fix Staging Manager --- staging-auto-merge/src/staging-auto-merge.js | 1 + staging-auto-merge/tests/staging-auto-merge.test.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/staging-auto-merge/src/staging-auto-merge.js b/staging-auto-merge/src/staging-auto-merge.js index db01551..76a364a 100644 --- a/staging-auto-merge/src/staging-auto-merge.js +++ b/staging-auto-merge/src/staging-auto-merge.js @@ -77,6 +77,7 @@ export default class StagingAutoMerge { try { await this.exec('git', ['merge', `origin/${branch}`, '--squash', '--verbose'], options) await this.exec('git', ['commit', '-m', title]) + await this.removeStagingLabel(number) } catch (error) { await this.abortMerge() await this.createMergeConflictComment(number, execOutput, execError) diff --git a/staging-auto-merge/tests/staging-auto-merge.test.js b/staging-auto-merge/tests/staging-auto-merge.test.js index 5bb4a0a..137b9c8 100644 --- a/staging-auto-merge/tests/staging-auto-merge.test.js +++ b/staging-auto-merge/tests/staging-auto-merge.test.js @@ -64,6 +64,12 @@ describe('StagingAutoMerge', () => { ) expect(execMock).toHaveBeenCalledWith('git', ['commit', '-m', 'Add feature']) expect(octokit.rest.issues.createComment).not.toHaveBeenCalled() + expect(octokit.rest.issues.removeLabel).toHaveBeenCalledWith({ + owner: 'rolemodel', + repo: 'actions', + issue_number: 12, + name: 'Staging', + }) expect(octokit.rest.issues.removeLabel).toHaveBeenCalledWith({ owner: 'rolemodel', repo: 'actions', From a2a943722e8917ed0b44412571fad234565edf11 Mon Sep 17 00:00:00 2001 From: Braden Rich Date: Thu, 11 Jun 2026 13:01:11 -0400 Subject: [PATCH 2/3] Update Dist --- staging-auto-merge/dist/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/staging-auto-merge/dist/index.js b/staging-auto-merge/dist/index.js index 186f3f0..61a7c8d 100644 --- a/staging-auto-merge/dist/index.js +++ b/staging-auto-merge/dist/index.js @@ -23275,6 +23275,7 @@ class StagingAutoMerge { try { await this.exec("git", ["merge", `origin/${branch}`, "--squash", "--verbose"], options); await this.exec("git", ["commit", "-m", title]); + await this.removeStagingLabel(number); } catch (error) { await this.abortMerge(); await this.createMergeConflictComment(number, execOutput, execError); From 3ddc9ee3c89d70c37965b40900bfdf4686751413 Mon Sep 17 00:00:00 2001 From: Braden Rich Date: Thu, 11 Jun 2026 13:09:06 -0400 Subject: [PATCH 3/3] Fix --- staging-auto-merge/dist/index.js | 8 +++----- staging-auto-merge/src/staging-auto-merge.js | 8 +++----- .../tests/staging-auto-merge.test.js | 20 ++++++++----------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/staging-auto-merge/dist/index.js b/staging-auto-merge/dist/index.js index 61a7c8d..b16e4ae 100644 --- a/staging-auto-merge/dist/index.js +++ b/staging-auto-merge/dist/index.js @@ -23275,7 +23275,6 @@ class StagingAutoMerge { try { await this.exec("git", ["merge", `origin/${branch}`, "--squash", "--verbose"], options); await this.exec("git", ["commit", "-m", title]); - await this.removeStagingLabel(number); } catch (error) { await this.abortMerge(); await this.createMergeConflictComment(number, execOutput, execError); @@ -23291,13 +23290,12 @@ class StagingAutoMerge { await this.exec("git push --force"); } async cleanupClosedPullRequests() { - const closedPullRequests = await this.octokit.rest.pulls.list({ + const closedPullRequests = await this.octokit.paginate(this.octokit.rest.pulls.list, { ...this.repo, state: "closed", - sort: "created", - direction: "desc" + per_page: 100 }); - for (const closedPr of closedPullRequests.data) { + for (const closedPr of closedPullRequests) { if (this.hasStagingLabel(closedPr.labels)) { this.logger.info("removing label from: ", closedPr.title); await this.removeStagingLabel(closedPr.number); diff --git a/staging-auto-merge/src/staging-auto-merge.js b/staging-auto-merge/src/staging-auto-merge.js index 76a364a..1529582 100644 --- a/staging-auto-merge/src/staging-auto-merge.js +++ b/staging-auto-merge/src/staging-auto-merge.js @@ -77,7 +77,6 @@ export default class StagingAutoMerge { try { await this.exec('git', ['merge', `origin/${branch}`, '--squash', '--verbose'], options) await this.exec('git', ['commit', '-m', title]) - await this.removeStagingLabel(number) } catch (error) { await this.abortMerge() await this.createMergeConflictComment(number, execOutput, execError) @@ -96,14 +95,13 @@ export default class StagingAutoMerge { } async cleanupClosedPullRequests() { - const closedPullRequests = await this.octokit.rest.pulls.list({ + const closedPullRequests = await this.octokit.paginate(this.octokit.rest.pulls.list, { ...this.repo, state: 'closed', - sort: 'created', - direction: 'desc', + per_page: 100, }) - for (const closedPr of closedPullRequests.data) { + for (const closedPr of closedPullRequests) { if (this.hasStagingLabel(closedPr.labels)) { this.logger.info('removing label from: ', closedPr.title) await this.removeStagingLabel(closedPr.number) diff --git a/staging-auto-merge/tests/staging-auto-merge.test.js b/staging-auto-merge/tests/staging-auto-merge.test.js index 137b9c8..f088dfe 100644 --- a/staging-auto-merge/tests/staging-auto-merge.test.js +++ b/staging-auto-merge/tests/staging-auto-merge.test.js @@ -1,6 +1,7 @@ import StagingAutoMerge from '../src/staging-auto-merge.js' const createOctokit = () => ({ + paginate: vi.fn(), rest: { issues: { listLabelsForRepo: vi.fn(), @@ -47,9 +48,8 @@ describe('StagingAutoMerge', () => { }, ] - octokit.rest.pulls.list.mockImplementation(({ state }) => - Promise.resolve({ data: state === 'open' ? openPulls : closedPulls }), - ) + octokit.rest.pulls.list.mockResolvedValue({ data: openPulls }) + octokit.paginate.mockResolvedValue(closedPulls) const stagingAutoMerge = new StagingAutoMerge(octokit, primaryBranch, repo, logger) const execMock = vi.fn().mockResolvedValue(undefined) @@ -64,12 +64,9 @@ describe('StagingAutoMerge', () => { ) expect(execMock).toHaveBeenCalledWith('git', ['commit', '-m', 'Add feature']) expect(octokit.rest.issues.createComment).not.toHaveBeenCalled() - expect(octokit.rest.issues.removeLabel).toHaveBeenCalledWith({ - owner: 'rolemodel', - repo: 'actions', - issue_number: 12, - name: 'Staging', - }) + expect(octokit.rest.issues.removeLabel).not.toHaveBeenCalledWith( + expect.objectContaining({ issue_number: 12 }), + ) expect(octokit.rest.issues.removeLabel).toHaveBeenCalledWith({ owner: 'rolemodel', repo: 'actions', @@ -88,9 +85,8 @@ describe('StagingAutoMerge', () => { }, ] - octokit.rest.pulls.list.mockImplementation(({ state }) => - Promise.resolve({ data: state === 'open' ? openPulls : [] }), - ) + octokit.rest.pulls.list.mockResolvedValue({ data: openPulls }) + octokit.paginate.mockResolvedValue([]) const stagingAutoMerge = new StagingAutoMerge(octokit, primaryBranch, repo, logger) const execMock = vi.fn(async (command, args, options) => {