mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Git - better error handling for git merge-base (#198208)
This commit is contained in:
parent
67aa71296f
commit
ed30010d3f
|
@ -189,7 +189,7 @@ export class ApiRepository implements Repository {
|
|||
return this.repository.getRefs(query, cancellationToken);
|
||||
}
|
||||
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string> {
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string | undefined> {
|
||||
return this.repository.getMergeBase(ref1, ref2);
|
||||
}
|
||||
|
||||
|
|
2
extensions/git/src/api/git.d.ts
vendored
2
extensions/git/src/api/git.d.ts
vendored
|
@ -233,7 +233,7 @@ export interface Repository {
|
|||
|
||||
getRefs(query: RefQuery, cancellationToken?: CancellationToken): Promise<Ref[]>;
|
||||
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string>;
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string | undefined>;
|
||||
|
||||
tag(name: string, upstream: string): Promise<void>;
|
||||
deleteTag(name: string): Promise<void>;
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -175,7 +175,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
|||
|
||||
async resolveHistoryItemGroupCommonAncestor(refId1: string, refId2: string): Promise<{ id: string; ahead: number; behind: number } | undefined> {
|
||||
const ancestor = await this.repository.getMergeBase(refId1, refId2);
|
||||
if (ancestor === '') {
|
||||
if (!ancestor) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -1189,7 +1189,7 @@ export class Repository implements Disposable {
|
|||
return this.run(Operation.Diff, () => this.repository.diffBetweenShortStat(ref1, ref2));
|
||||
}
|
||||
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string> {
|
||||
getMergeBase(ref1: string, ref2: string): Promise<string | undefined> {
|
||||
return this.run(Operation.MergeBase, () => this.repository.getMergeBase(ref1, ref2));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue