From 73072937bc890faf273b8cd978cb7f64c8e155da Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:47:38 +0100 Subject: [PATCH] Git - deduplicate annotated and lightweight tags when showing the quick pick for tags (#172527) --- extensions/git/src/commands.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 9fe7ff2b275..83a94ffc7d2 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2460,7 +2460,20 @@ export class CommandCenter { } const remoteTagPicks = async (): Promise => { - 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(); + 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)); };