From 42f6c5b29549f79431e5ce5d619fbd5453800bfb Mon Sep 17 00:00:00 2001
From: Maksim <m.v.sharipov@gmail.com>
Date: Sat, 7 Aug 2021 18:11:57 +0200
Subject: [PATCH] fix(bitbucket-server): handle push rejection properly
 (#11154)

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

diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index ac735d03c5..c19deea75d 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -837,6 +837,15 @@ export async function commitFiles({
       error.validationMessage = `Renovate cannot push to its branch because branch protection has been enabled.`;
       throw error;
     }
+    if (err.message.includes('can only push your own commits')) {
+      const error = new Error(CONFIG_VALIDATION);
+      error.validationSource = branchName;
+      error.validationError = 'Bitbucket committer error';
+      error.validationMessage = `Renovate has experienced the following error when attempting to push its branch to the server: "${String(
+        err.message
+      )}"`;
+      throw error;
+    }
     if (err.message.includes('remote: error: cannot lock ref')) {
       logger.error({ err }, 'Error committing files.');
       return null;
-- 
GitLab