diff --git a/lib/workers/branch/index.js b/lib/workers/branch/index.js index 41900187f5a4696abd5f1f02771bf1029fe7ba09..cd382564b9788cfe421dea7340527614f498f7db 100644 --- a/lib/workers/branch/index.js +++ b/lib/workers/branch/index.js @@ -122,7 +122,11 @@ async function processBranch(branchConfig, prHourlyLimitReached, packageFiles) { ); throw new Error('repository-changed'); } - if (!branchPr.canRebase) { + if ( + !branchPr.canRebase || + (branchPr.targetBranch && + branchPr.targetBranch !== branchConfig.baseBranch) + ) { const subject = 'PR has been edited'; if (masterIssueCheck || config.rebaseRequested) { if (config.dryRun) { diff --git a/test/workers/branch/index.spec.js b/test/workers/branch/index.spec.js index 640e5c01bcd7392a59ae647d58c7b3cb91c4605a..5027e424c3f2ee8b7aa7ffe5b7bed3e0a51c1be6 100644 --- a/test/workers/branch/index.spec.js +++ b/test/workers/branch/index.spec.js @@ -159,6 +159,18 @@ describe('workers/branch', () => { const res = await branchWorker.processBranch(config); expect(res).toEqual('pr-edited'); }); + it('skips branch if target branch changed', async () => { + schedule.isScheduledNow.mockReturnValueOnce(false); + platform.branchExists.mockReturnValueOnce(true); + platform.getBranchPr.mockReturnValueOnce({ + state: 'open', + canRebase: true, + targetBranch: 'v6', + }); + config.baseBranch = 'master'; + const res = await branchWorker.processBranch(config); + expect(res).toEqual('pr-edited'); + }); it('returns if pr creation limit exceeded', async () => { getUpdated.getUpdatedPackageFiles.mockReturnValueOnce({ updatedPackageFiles: [],