Skip to content

Commit

Permalink
fix(git): try/catch isBranchStale
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Oct 19, 2020
1 parent bb9e30f commit a8fdb4e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/util/git/index.ts
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit a8fdb4e

Please sign in to comment.