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,6 +406,7 @@ 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);
try {
const branches = await git.branch([ const branches = await git.branch([
'--remotes', '--remotes',
'--verbose', '--verbose',
@ -412,6 +414,10 @@ export async function isBranchStale(branchName: string): Promise<boolean> {
config.currentBranchSha, 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> {