fix(git): try/catch isBranchStale

This commit is contained in:
Rhys Arkins 2020-10-19 10:14:28 +02:00
parent bb9e30f64a
commit a8fdb4e38c

View file

@ -64,6 +64,7 @@ function checkForPlatformFailure(err: Error): void {
'Could not write new index file', 'Could not write new index file',
'Failed to connect to', 'Failed to connect to',
'Connection timed out', 'Connection timed out',
'malformed object name',
]; ];
for (const errorStr of platformFailureStrings) { for (const errorStr of platformFailureStrings) {
if (err.message.includes(errorStr)) { if (err.message.includes(errorStr)) {
@ -405,13 +406,18 @@ export function getBranchList(): string[] {
export async function isBranchStale(branchName: string): Promise<boolean> { export async function isBranchStale(branchName: string): Promise<boolean> {
await syncBranch(branchName); await syncBranch(branchName);
const branches = await git.branch([ try {
'--remotes', const branches = await git.branch([
'--verbose', '--remotes',
'--contains', '--verbose',
config.currentBranchSha, '--contains',
]); config.currentBranchSha,
return !branches.all.map(localName).includes(branchName); ]);
return !branches.all.map(localName).includes(branchName);
} catch (err) /* istanbul ignore next */ {
checkForPlatformFailure(err);
throw err;
}
} }
export async function isBranchModified(branchName: string): Promise<boolean> { export async function isBranchModified(branchName: string): Promise<boolean> {