From 19116fc6edb1cea339738e91eb874ed7e565b61c Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 16 Aug 2018 12:04:44 +0200 Subject: [PATCH] refactor: remove legacy closed PR check --- lib/workers/branch/check-existing.js | 23 +--------------------- test/workers/branch/check-existing.spec.js | 10 ++-------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/lib/workers/branch/check-existing.js b/lib/workers/branch/check-existing.js index 0b788635df..c5b8ad9116 100644 --- a/lib/workers/branch/check-existing.js +++ b/lib/workers/branch/check-existing.js @@ -10,32 +10,11 @@ async function prAlreadyExisted(config) { } logger.debug('recreateClosed is false'); // Return if same PR already existed - // Check for current PR title format - // See #1205 for why we check for !open or closed - const statusValue = - config.packageFiles && config.packageFiles.length === 1 - ? '!open' - : 'closed'; - let pr = await platform.findPr( - config.branchName, - config.prTitle, - statusValue - ); + const pr = await platform.findPr(config.branchName, config.prTitle, '!open'); if (pr) { logger.debug('Found closed PR with current title'); return pr; } - // Check for legacy PR title format - // TODO: remove this once not found anymore - const legacyPrTitle = config.prTitle - .replace(/to v(\d+)$/, 'to version $1.x') // Major - .replace(/to v(\d+)/, 'to version $1'); // Non-major - pr = await platform.findPr(config.branchName, legacyPrTitle, statusValue); - if (pr) { - logger.info({ pr }, 'Found closed PR with legacy title'); - await platform.updatePr(pr.number, config.prTitle); - return pr; - } logger.debug('prAlreadyExisted=false'); return null; } diff --git a/test/workers/branch/check-existing.spec.js b/test/workers/branch/check-existing.spec.js index 649d4d1612..4cc88374a3 100644 --- a/test/workers/branch/check-existing.spec.js +++ b/test/workers/branch/check-existing.spec.js @@ -19,21 +19,15 @@ describe('workers/branch/check-existing', () => { expect(await prAlreadyExisted(config)).toBe(null); expect(platform.findPr.mock.calls.length).toBe(0); }); - it('returns false if both checks miss', async () => { + it('returns false if check misses', async () => { config.recreatedClosed = true; expect(await prAlreadyExisted(config)).toBe(null); - expect(platform.findPr.mock.calls.length).toBe(2); + expect(platform.findPr.mock.calls.length).toBe(1); }); it('returns true if first check hits', async () => { platform.findPr.mockReturnValueOnce({ number: 12 }); expect(await prAlreadyExisted(config)).toEqual({ number: 12 }); expect(platform.findPr.mock.calls.length).toBe(1); }); - it('returns true if second check hits', async () => { - platform.findPr.mockReturnValueOnce(null); - platform.findPr.mockReturnValueOnce({ number: 13 }); - expect(await prAlreadyExisted(config)).toEqual({ number: 13 }); - expect(platform.findPr.mock.calls.length).toBe(2); - }); }); }); -- GitLab