From a67d8a4f8747eae11ea18bc652324ad38dbba510 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 31 Mar 2021 22:14:17 +0200 Subject: [PATCH] fix(github): catch branch protection and raise config error (#9340) --- 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 e06e53fe91..5e03779ec0 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -713,6 +713,13 @@ export async function commitFiles({ ); return null; } + if (err.message.includes('protected branch hook declined')) { + const error = new Error(CONFIG_VALIDATION); + error.configFile = branchName; + error.validationError = 'Renovate branch is protected'; + error.validationMessage = `Renovate cannot push to its branch because branch protection has been enabled.`; + throw error; + } if (err.message.includes('remote: error: cannot lock ref')) { logger.error({ err }, 'Error committing files.'); return null; -- GitLab