feat: Add copy link to tag support#403
Conversation
|
Hi @alnoki. Thanks for contributing, and sorry for taking so long to look at this. I haven't given this a thorough review yet, but I do have a few concerns about tag support. SupportThe first problem is whether all providers (GitHub, GitLab, Azure Dev Ops, etc) treat tags the same way that the treat branch names. For example, VSTS uses different query parameter values for commits and branches. In the worst case, I'm happy to restrict tag support to providers that can easily be supported. Visual StudioThe next thing is keeping the VS Code and Visual Studio extensions in sync. This PR only changes the VS Code extension. Equivalent changes will need to be made to the Visual Studio extension. I would recommend not making those changes yet, because the changes in the VS Code extension might end up needing to change. PerformanceAnd lastly, there is a performance consideration. When you select a branch or commit (the commits are just the SHAs of the branches), it's limited to what branches you have in your local repository. That may not be every branch that exists in the remote, so the list is probably not huge. However, when listing tags, the list would contain every tag that exists locally. For large repositories, that could be a very large list. For example, https://github.com/renovatebot/renovate has over 11,000 tags. Because of this performance impact, I'm not convinced that just populating the list with all tags is the right approach. I'll need to give it some more thought. |
|
@reduckted thanks for the detailed analysis! Assorted responses:
|
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
tagoption for thegitweblinks.linkTypesetting to use tags by defaultFiles Modified
src/types.ts- Added'tag'toLinkTypeandLinkTargetRef.typeunionssrc/constants.ts- AddedcopySelectionToTagcommand constantsrc/settings.ts- Handle'tag'ingetDefaultLinkType()src/link-handler.ts- Added'tag'case ingetRef()usinggit describe --exact-match --tags HEADsrc/commands/get-link-command.ts- Added "Current tag" preset and "Tags" section in quick picksrc/commands/index.ts- RegisteredcopySelectionToTagcommandpackage.json- Added command definition and'tag'tolinkTypeenumTest Updates
The quick pick item indices in
get-link-command.test.tswere updated to account for the new structure:Previous structure (10 items):
New structure (12 items):
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
git describe --exact-match --tags HEADfor the current taggit tag -l --format='%(refname:short) %(objectname:short) %(objectname)'{{ ref }}placeholder contains the tag name)