[Code]: ignore annotated tags that can't be peeled (#37917)

This commit is contained in:
Fuyao Zhao 2019-06-03 15:08:12 -07:00 committed by GitHub
parent a5df2ee962
commit c1056d243b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View file

@ -531,10 +531,15 @@ export function commitInfo(commit: Commit): CommitInfo {
};
}
export async function referenceInfo(ref: Reference): Promise<ReferenceInfo> {
export async function referenceInfo(ref: Reference): Promise<ReferenceInfo | null> {
const repository = ref.owner();
const object = await ref.peel(Object.TYPE.COMMIT);
const commit = await repository.getCommit(object.id());
let commit: CommitInfo | undefined;
try {
const object = await ref.peel(Object.TYPE.COMMIT);
commit = commitInfo(await repository.getCommit(object.id()));
} catch {
return null;
}
let type: ReferenceType;
if (ref.isTag()) {
type = ReferenceType.TAG;
@ -548,7 +553,7 @@ export async function referenceInfo(ref: Reference): Promise<ReferenceInfo> {
return {
name: ref.shorthand(),
reference: ref.name(),
commit: commitInfo(commit),
commit,
type,
};
}

View file

@ -220,7 +220,8 @@ export function fileRoute(server: CodeServerRouter, options: ServerOptions) {
try {
const repository = await gitOperations.openRepo(uri);
const references = await repository.getReferences(Reference.TYPE.DIRECT);
return await Promise.all(references.map(referenceInfo));
const referenceInfos = await Promise.all(references.map(referenceInfo));
return referenceInfos.filter(info => info !== null);
} catch (e) {
if (e.isBoom) {
return e;