Git - deduplicate annotated and lightweight tags when showing the quick pick for tags (#172527)

This commit is contained in:
Ladislau Szomoru
2023-01-26 15:47:38 +01:00
committed by GitHub
parent dde818e256
commit 73072937bc
+14 -1
View File
@@ -2460,7 +2460,20 @@ export class CommandCenter {
}
const remoteTagPicks = async (): Promise<TagItem[] | QuickPickItem[]> => {
const remoteTags = await repository.getRemoteRefs(remoteName, { tags: true });
const remoteTagsRaw = await repository.getRemoteRefs(remoteName, { tags: true });
// Deduplicate annotated and lightweight tags
const remoteTagNames = new Set<string>();
const remoteTags: Ref[] = [];
for (const tag of remoteTagsRaw) {
const tagName = (tag.name ?? '').replace(/\^{}$/, '');
if (!remoteTagNames.has(tagName)) {
remoteTags.push({ ...tag, name: tagName });
remoteTagNames.add(tagName);
}
}
return remoteTags.length === 0 ? [{ label: l10n.t('$(info) Remote "{0}" has no tags.', remoteName) }] : remoteTags.map(ref => new TagItem(ref));
};