Skip to content
Snippets Groups Projects
Commit bc074aff authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: check PR is closed when finding blocking PR

Closes #2391
parent 19116fc6
No related branches found
No related tags found
No related merge requests found
......@@ -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');
......
......@@ -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);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment