diff --git a/lib/workers/branch/check-existing.js b/lib/workers/branch/check-existing.js index c5b8ad91162194bb386d0269602181f4853c80be..144525d611fcc5cbfce7096514fc216592f88fcf 100644 --- a/lib/workers/branch/check-existing.js +++ b/lib/workers/branch/check-existing.js @@ -13,6 +13,12 @@ async function prAlreadyExisted(config) { const pr = await platform.findPr(config.branchName, config.prTitle, '!open'); if (pr) { logger.debug('Found closed PR with current title'); + const prDetails = await platform.getPr(pr.number); + // istanbul ignore if + if (prDetails.state === 'open') { + logger.debug('PR reopened'); + throw new Error('repository-changed'); + } return pr; } logger.debug('prAlreadyExisted=false'); diff --git a/test/workers/branch/check-existing.spec.js b/test/workers/branch/check-existing.spec.js index 4cc88374a3520c4ba89a5d6c17cb8a041def4070..675f17dae05fabe68a59498cda768aa7e8c2502c 100644 --- a/test/workers/branch/check-existing.spec.js +++ b/test/workers/branch/check-existing.spec.js @@ -26,6 +26,7 @@ describe('workers/branch/check-existing', () => { }); it('returns true if first check hits', async () => { platform.findPr.mockReturnValueOnce({ number: 12 }); + platform.getPr.mockReturnValueOnce({ number: 12, state: 'closed' }); expect(await prAlreadyExisted(config)).toEqual({ number: 12 }); expect(platform.findPr.mock.calls.length).toBe(1); });