From d2ee36f0c8b890596dad8411bbe7f3088b5a5cbe Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 24 Jan 2019 07:00:45 +0100 Subject: [PATCH] fix: Revert "feat(automerge): merge passing branch even if PR exists (#3097)" This reverts commit 514d527d7aeb1d167e84d1d48dd1382205cd3097. --- lib/workers/branch/automerge.js | 16 +++------------- test/workers/branch/automerge.spec.js | 17 +---------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/lib/workers/branch/automerge.js b/lib/workers/branch/automerge.js index 0bd8952ca4..2e878306d4 100644 --- a/lib/workers/branch/automerge.js +++ b/lib/workers/branch/automerge.js @@ -8,23 +8,13 @@ async function tryBranchAutomerge(config) { return 'no automerge'; } const existingPr = await platform.getBranchPr(config.branchName); - + if (existingPr) { + return 'automerge aborted - PR exists'; + } const branchStatus = await platform.getBranchStatus( config.branchName, config.requiredStatusChecks ); - - if (existingPr) { - if (branchStatus === 'success') { - if (existingPr.canRebase) { - await platform.mergeBranch(config.branchName, config.automergeType); - logger.info({ branch: config.branchName }, 'Branch automerged'); - return 'automerged'; // Branch no longer exists - } - return 'automerge aborted - Human commits detected'; - } - return 'automerge aborted - PR exists'; - } if (branchStatus === 'success') { logger.debug(`Automerging branch`); try { diff --git a/test/workers/branch/automerge.spec.js b/test/workers/branch/automerge.spec.js index 36394db797..3fbdd5cd55 100644 --- a/test/workers/branch/automerge.spec.js +++ b/test/workers/branch/automerge.spec.js @@ -31,20 +31,12 @@ describe('workers/branch/automerge', () => { expect(await tryBranchAutomerge(config)).toBe('branch status error'); }); it('returns false if PR exists', async () => { - platform.getBranchPr.mockReturnValueOnce({}); - config.automerge = true; - config.automergeType = 'branch'; - expect(await tryBranchAutomerge(config)).toBe( - 'automerge aborted - PR exists' - ); - }); - it('returns false if PR exists and success branch', async () => { platform.getBranchPr.mockReturnValueOnce({}); config.automerge = true; config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('success'); expect(await tryBranchAutomerge(config)).toBe( - 'automerge aborted - Human commits detected' + 'automerge aborted - PR exists' ); }); it('returns false if automerge fails', async () => { @@ -62,12 +54,5 @@ describe('workers/branch/automerge', () => { platform.getBranchStatus.mockReturnValueOnce('success'); expect(await tryBranchAutomerge(config)).toBe('automerged'); }); - it('merge branch if PR exists and have one commit and success branch', async () => { - platform.getBranchPr.mockReturnValueOnce({ canRebase: true }); - config.automerge = true; - config.automergeType = 'branch'; - platform.getBranchStatus.mockReturnValueOnce('success'); - expect(await tryBranchAutomerge(config)).toBe('automerged'); - }); }); }); -- GitLab