From f5d4afecf70b30fc245b5a0242b205e5f82a507e Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Thu, 1 Apr 2021 07:01:02 +0200
Subject: [PATCH] fix(git): throw config error if branch is blocking (#9341)

---
 lib/util/git/index.ts | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index 5e03779ec0..216a63edea 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -703,6 +703,13 @@ export async function commitFiles({
     return commit;
   } catch (err) /* istanbul ignore next */ {
     checkForPlatformFailure(err);
+    if (err.message.includes(`'refs/heads/renovate' exists`)) {
+      const error = new Error(CONFIG_VALIDATION);
+      error.configFile = 'None';
+      error.validationError = 'An existing branch is blocking Renovate';
+      error.validationMessage = `Renovate needs to create the branch "${branchName}" but is blocked from doing so because of an existing branch called "renovate". Please remove it so that Renovate can proceed.`;
+      throw error;
+    }
     if (
       err.message.includes(
         'refusing to allow a GitHub App to create or update workflow'
-- 
GitLab