diff --git a/lib/workers/repository/process/write.spec.ts b/lib/workers/repository/process/write.spec.ts index 3fdb37d395b41afa64e69dae9656d08db6f922b6..f6c85a32bc3c66a8117cf657ee31bfaaae33ebb4 100644 --- a/lib/workers/repository/process/write.spec.ts +++ b/lib/workers/repository/process/write.spec.ts @@ -30,13 +30,20 @@ describe('workers/repository/write', () => { expect(branchWorker.processBranch).toHaveBeenCalledTimes(2); }); it('stops after automerge', async () => { - const branches: BranchConfig[] = [{}, {}, {}, {}] as never; + const branches: BranchConfig[] = [ + {}, + {}, + { automergeType: 'pr-comment', requiredStatusChecks: null }, + {}, + {}, + ] as never; branchWorker.processBranch.mockResolvedValueOnce('pr-created'); branchWorker.processBranch.mockResolvedValueOnce('already-existed'); branchWorker.processBranch.mockResolvedValueOnce('automerged'); + branchWorker.processBranch.mockResolvedValueOnce('automerged'); const res = await writeUpdates(config, branches); expect(res).toEqual('automerged'); - expect(branchWorker.processBranch).toHaveBeenCalledTimes(3); + expect(branchWorker.processBranch).toHaveBeenCalledTimes(4); }); }); }); diff --git a/lib/workers/repository/process/write.ts b/lib/workers/repository/process/write.ts index cc41caa8e33df34370cb26011ff4593dcba2fc15..432b3b6cab47769355d6741b2b3d19514b4dae1d 100644 --- a/lib/workers/repository/process/write.ts +++ b/lib/workers/repository/process/write.ts @@ -36,7 +36,7 @@ export async function writeUpdates( prsRemaining <= 0 || getLimitRemaining('prCommitsPerRunLimit') <= 0 ); branch.res = res; - if (res === 'automerged' && config.automergeType !== 'pr-comment') { + if (res === 'automerged' && branch.automergeType !== 'pr-comment') { // Stop procesing other branches because base branch has been changed return res; } @@ -47,8 +47,8 @@ export async function writeUpdates( // istanbul ignore if if ( res === 'automerged' && - config.automergeType === 'pr-comment' && - config.requiredStatusChecks === null + branch.automergeType === 'pr-comment' && + branch.requiredStatusChecks === null ) { deductPrRemainingCount = 1; }