From c62cdbfebbe644e8b20c581dee7cf94595756870 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Thu, 21 Oct 2021 13:14:00 +0200
Subject: [PATCH] fix(git): use rev-parse to get default branch (#12248)

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

diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts
index 345fb32af8..fc808081ee 100644
--- a/lib/util/git/index.ts
+++ b/lib/util/git/index.ts
@@ -131,10 +131,10 @@ async function isDirectory(dir: string): Promise<boolean> {
 }
 
 async function getDefaultBranch(git: SimpleGit): Promise<string> {
-  // see https://stackoverflow.com/a/44750379/1438522
+  // see https://stackoverflow.com/a/62352647/3005034
   try {
-    const res = await git.raw(['symbolic-ref', 'refs/remotes/origin/HEAD']);
-    return res.replace('refs/remotes/origin/', '').trim();
+    const res = await git.raw(['rev-parse', '--abbrev-ref', 'origin/HEAD']);
+    return res.replace('origin/', '').trim();
   } catch (err) /* istanbul ignore next */ {
     checkForPlatformFailure(err);
     if (
-- 
GitLab