diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 99e60ab0c932f8e23aa362f3f7f0e7cd9bf9de8b..891bdb4b2a083e696fdca7218142df0c4a671eef 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(