diff --git a/src/autoupdater.ts b/src/autoupdater.ts index 16983c44..794d27ee 100644 --- a/src/autoupdater.ts +++ b/src/autoupdater.ts @@ -122,6 +122,13 @@ export class AutoUpdater { mergeOpts.commit_message = mergeMsg; } + try { + await this.merge(mergeOpts); + } catch (e) { + ghCore.info(`Autoupdate will attempt to update any remaining PRs.`); + return false; + } + await this.merge(mergeOpts); return true; diff --git a/test/autoupdate.test.ts b/test/autoupdate.test.ts index 898de3b3..e5e2a96e 100644 --- a/test/autoupdate.test.ts +++ b/test/autoupdate.test.ts @@ -326,6 +326,7 @@ describe('test `handlePush`', () => { name: repo, }, }; + const cloneEvent = () => JSON.parse(JSON.stringify(dummyEvent)); test('push event on a non-branch', async () => { @@ -604,4 +605,20 @@ describe('test `merge`', () => { expect(scope.isDone()).toEqual(true); }); + + test('autoupdate continues with valid PRs if merging throws an error', async () => { + const mergeMsg = 'dummy-merge-msg'; + (config.mergeMsg as jest.Mock).mockReturnValue(mergeMsg); + (config.dryRun as jest.Mock).mockReturnValue(false); + + const updater = new AutoUpdater(config, {}); + + jest.spyOn(updater, 'prNeedsUpdate').mockResolvedValue(true); + jest.spyOn(updater, 'merge').mockImplementation(() => { + throw new Error('Resource not accessible by integration'); + }); + + const updated = await updater.update(validPull); + expect(updated).toEqual(false); + }); });