From d9c1521f73ca8528e96b70d3dff176d9e2f13100 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 28 Mar 2018 16:07:51 +0200 Subject: [PATCH] fix: delete blocking branch before attempting create --- lib/platform/github/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 99e60ab0c9..891bdb4b2a 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -1140,9 +1140,17 @@ async function createBranch(branchName, sha) { options.token = config.forkToken; } 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'); await get.post(`repos/${config.repository}/git/refs`, options); + config.branchList.push(branchName); logger.debug('Created branch'); } catch (err) /* istanbul ignore next */ { logger.warn( -- GitLab