diff --git a/lib/manager/index.js b/lib/manager/index.js index a64be4cc910497cd2da1baf2efbe101017b105ab..e9672c8d79157f00285ca4d756df906e2c4f5fa9 100644 --- a/lib/manager/index.js +++ b/lib/manager/index.js @@ -108,7 +108,7 @@ async function getUpdatedPackageFiles(config) { newContent = await bazelHelper.setNewValue(existingContent, upgrade); } if (!newContent) { - if (config.parentBranch && config.canRebase) { + if (config.parentBranch) { logger.info('Rebasing branch after error updating content'); return getUpdatedPackageFiles({ ...config, @@ -118,7 +118,7 @@ async function getUpdatedPackageFiles(config) { throw new Error('Error updating branch content and cannot rebase'); } if (newContent !== existingContent) { - if (config.parentBranch && config.canRebase) { + if (config.parentBranch) { // This ensure it's always 1 commit from Renovate logger.info('Need to update package file so will rebase first'); return getUpdatedPackageFiles({ diff --git a/lib/workers/branch/index.js b/lib/workers/branch/index.js index 19fdd88224289a2feeed104d4f79f2a1f43be3c1..84f8186070fe2d35cc13fe4c2a841ece7153eb32 100644 --- a/lib/workers/branch/index.js +++ b/lib/workers/branch/index.js @@ -30,7 +30,7 @@ async function processBranch(branchConfig) { logger.info(`Branch has ${dependencies.length} upgrade(s)`); // Check if branch already existed - const pr = await prAlreadyExisted(config); + let pr = await prAlreadyExisted(config); if (pr) { logger.info( { prTitle: config.prTitle }, @@ -60,6 +60,22 @@ async function processBranch(branchConfig) { await platform.ensureComment(pr.number, subject, content); return 'already-existed'; } + logger.debug('Checking if PR has been edited'); + pr = await platform.findPr(config.branchName, config.prTitle, 'open'); + if (pr) { + logger.debug('Open PR already exists'); + pr = await platform.getPr(pr.number); + if (!pr.canRebase) { + logger.info('PR has been edited'); + const subject = 'PR has been edited'; + let content = + 'As this PR has been edited, Renovate will stop updating it in order to not cause any conflicts or other problems.'; + content += + ' If you wish to abandon your edits and have Renovate recreate this PR then you should rename this PR and then close it.'; + await platform.ensureComment(pr.number, subject, content); + return 'pr-edited'; + } + } // Check schedule config.isScheduledNow = isScheduledNow(config); diff --git a/test/workers/branch/index.spec.js b/test/workers/branch/index.spec.js index d8d583234a084b7e8747e30e691c99435061af07..90acab8a1e00df507beac974a1016aea5f94148b 100644 --- a/test/workers/branch/index.spec.js +++ b/test/workers/branch/index.spec.js @@ -82,6 +82,14 @@ describe('workers/branch', () => { await branchWorker.processBranch(config); expect(parent.getParentBranch.mock.calls.length).toBe(0); }); + it('skips branch if edited PR found', async () => { + schedule.isScheduledNow.mockReturnValueOnce(false); + platform.branchExists.mockReturnValueOnce(true); + platform.findPr.mockReturnValueOnce({}); + platform.getPr.mockReturnValueOnce({ canRebase: false }); + const res = await branchWorker.processBranch(config); + expect(res).toEqual('pr-edited'); + }); it('returns if no work', async () => { manager.getUpdatedPackageFiles.mockReturnValueOnce({ updatedPackageFiles: [],