Skip to content

Conversation

@alnoki
Copy link

@alnoki alnoki commented Jan 31, 2026

Add Tag Support for Permalinks

Summary

This PR adds support for creating permalinks to Git tags, alongside the existing branch, commit, and default branch options. Tags provide a more readable alternative to commit hashes for versioned releases.

Changes

New Features

  • "Copy Link to Selection (at current tag)" command - directly copy a link using the current tag (if HEAD is at a tag)
  • "Current tag" preset option in the "choose type" quick pick dialog
  • "Tags" section in the quick pick showing all repository tags
  • tag option for the gitweblinks.linkType setting to use tags by default

Files Modified

  • src/types.ts - Added 'tag' to LinkType and LinkTargetRef.type unions
  • src/constants.ts - Added copySelectionToTag command constant
  • src/settings.ts - Handle 'tag' in getDefaultLinkType()
  • src/link-handler.ts - Added 'tag' case in getRef() using git describe --exact-match --tags HEAD
  • src/commands/get-link-command.ts - Added "Current tag" preset and "Tags" section in quick pick
  • src/commands/index.ts - Registered copySelectionToTag command
  • package.json - Added command definition and 'tag' to linkType enum

Test Updates

The quick pick item indices in get-link-command.test.ts were updated to account for the new structure:

Previous structure (10 items):

  • 3 presets → "Branches" separator → 3 branches → "Commits" separator → 3 commits

New structure (12 items):

  • 4 presets (added "Current tag") → "Branches" separator → 3 branches → "Tags" separator → "Commits" separator → 3 commits

This shifted the branch item indices by 1 (from [4,5,6] to [5,6,7]) and commit item indices by 2 (from [8,9,10] to [10,11,12]).

Implementation Details

  • Tags are retrieved using git describe --exact-match --tags HEAD for the current tag
  • All tags are listed using git tag -l --format='%(refname:short) %(objectname:short) %(objectname)'
  • If HEAD is not at a tag, the "Current tag" preset shows an empty description
  • Tags use the same URL template as branches (the {{ ref }} placeholder contains the tag name)

@alnoki alnoki requested a review from reduckted as a code owner January 31, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant