Git - better error handling for git merge-base (#198208)

This commit is contained in:
Ladislau Szomoru
2023-11-14 14:51:17 +01:00
committed by GitHub
parent 67aa71296f
commit ed30010d3f
5 changed files with 13 additions and 8 deletions

View File

@@ -1434,11 +1434,16 @@ export class Repository {
return result;
}
async getMergeBase(ref1: string, ref2: string): Promise<string> {
const args = ['merge-base', ref1, ref2];
const result = await this.exec(args);
async getMergeBase(ref1: string, ref2: string): Promise<string | undefined> {
try {
const args = ['merge-base', ref1, ref2];
const result = await this.exec(args);
return result.stdout.trim();
return result.stdout.trim();
}
catch (err) {
return undefined;
}
}
async hashObject(data: string): Promise<string> {