Skip to content

Commit 7307293

Browse files
authored
Git - deduplicate annotated and lightweight tags when showing the quick pick for tags (microsoft#172527)
1 parent dde818e commit 7307293

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extensions/git/src/commands.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,20 @@ export class CommandCenter {
24602460
}
24612461

24622462
const remoteTagPicks = async (): Promise<TagItem[] | QuickPickItem[]> => {
2463-
const remoteTags = await repository.getRemoteRefs(remoteName, { tags: true });
2463+
const remoteTagsRaw = await repository.getRemoteRefs(remoteName, { tags: true });
2464+
2465+
// Deduplicate annotated and lightweight tags
2466+
const remoteTagNames = new Set<string>();
2467+
const remoteTags: Ref[] = [];
2468+
2469+
for (const tag of remoteTagsRaw) {
2470+
const tagName = (tag.name ?? '').replace(/\^{}$/, '');
2471+
if (!remoteTagNames.has(tagName)) {
2472+
remoteTags.push({ ...tag, name: tagName });
2473+
remoteTagNames.add(tagName);
2474+
}
2475+
}
2476+
24642477
return remoteTags.length === 0 ? [{ label: l10n.t('$(info) Remote "{0}" has no tags.', remoteName) }] : remoteTags.map(ref => new TagItem(ref));
24652478
};
24662479

0 commit comments

Comments
 (0)