From a8fdb4e38cdcd7f4b24a3f9b722d3fc5bf3424d2 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 19 Oct 2020 10:14:28 +0200 Subject: [PATCH] fix(git): try/catch isBranchStale --- lib/util/git/index.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 296c99a749..d7857a5fab 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -64,6 +64,7 @@ function checkForPlatformFailure(err: Error): void { 'Could not write new index file', 'Failed to connect to', 'Connection timed out', + 'malformed object name', ]; for (const errorStr of platformFailureStrings) { if (err.message.includes(errorStr)) { @@ -405,13 +406,18 @@ export function getBranchList(): string[] { export async function isBranchStale(branchName: string): Promise<boolean> { await syncBranch(branchName); - const branches = await git.branch([ - '--remotes', - '--verbose', - '--contains', - config.currentBranchSha, - ]); - return !branches.all.map(localName).includes(branchName); + try { + const branches = await git.branch([ + '--remotes', + '--verbose', + '--contains', + config.currentBranchSha, + ]); + return !branches.all.map(localName).includes(branchName); + } catch (err) /* istanbul ignore next */ { + checkForPlatformFailure(err); + throw err; + } } export async function isBranchModified(branchName: string): Promise<boolean> { -- GitLab