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

fix: delete blocking branch before attempting create

parent b724a411
No related branches found
No related tags found
No related merge requests found
...@@ -1140,9 +1140,17 @@ async function createBranch(branchName, sha) { ...@@ -1140,9 +1140,17 @@ async function createBranch(branchName, sha) {
options.token = config.forkToken; options.token = config.forkToken;
} }
try { try {
config.branchList.push(branchName); // istanbul ignore if
if (branchName.includes('/')) {
const [blockingBranch] = branchName.split('/');
if (await branchExists(blockingBranch)) {
logger.warn({ blockingBranch }, 'Deleting blocking branch');
await deleteBranch(blockingBranch);
}
}
logger.debug({ options, branchName }, 'Creating branch'); logger.debug({ options, branchName }, 'Creating branch');
await get.post(`repos/${config.repository}/git/refs`, options); await get.post(`repos/${config.repository}/git/refs`, options);
config.branchList.push(branchName);
logger.debug('Created branch'); logger.debug('Created branch');
} catch (err) /* istanbul ignore next */ { } catch (err) /* istanbul ignore next */ {
logger.warn( logger.warn(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment