Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 15, 2025

Summary

Adds a --what-if switch to the nbgv tag command that outputs the tag name that would be created without actually creating the tag.

Motivation

Users need to know what tag name will be generated for a specific commit without creating the tag. This is particularly useful in CI/CD workflows where tag names need to be passed between pipeline steps or jobs. Previously, users had to either:

  1. Hardcode the tag format (duplicating the format from version.json)
  2. Create the tag just to get its name

This creates a maintenance burden as any changes to version.json tag format require updating hardcoded values in workflow files.

Changes

  • Added --what-if boolean option to the nbgv tag command
  • When specified, the command calculates and outputs the tag name to stdout without creating the tag
  • Interactive commit selection (when multiple commits match a version) still works with --what-if
  • The last line written to stdout is always the tag name

Usage

# Preview tag name without creating it
$ nbgv tag --what-if
v1.2.3

# Works with custom tag formats defined in version.json
$ nbgv tag --what-if
release-1.2.3

# Can be used with specific version or commit
$ nbgv tag 1.2.3 --what-if
v1.2.3

# Normal tag creation unchanged
$ nbgv tag
v1.2.3 tag created at abc123...
Remember to push to a remote: git push origin v1.2.3

Example Workflow Integration

- name: Get tag name
  id: get-tag
  run: echo "tag=$(nbgv tag --what-if)" >> $GITHUB_OUTPUT

- name: Use tag in later step
  run: echo "Will create tag ${{ steps.get-tag.outputs.tag }}"
  
- name: Create tag when ready
  run: nbgv tag

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] Provide a way to get the tag name for the current context without actually creating the tag</issue_title>
<issue_description>We have a situation where we want to know what the tag name will be for a certain codebase/folder but we want to delay the creation of said tag to later.

The nbgv tag command only provides a means to tag a commit on the spot using the rules from the closest version.json. The variables created by the NuGet package also don't include the tag name today, even with "setAllVariables": true.

I would like to propose that the tag name be output in either one or both of these approaches, so that we can read what the tag name value will be, and be able to pass it along to a future step (we currently use this information in a future GitHub Actions job, so we pass it as a step/job output).

Perhaps for variables, there could be a new NBGV_TagName variable. And for nbgv tag, something similar to nbgv get-version could be done (either as a separate get-tag command, or an option on the existing tag command).

Our workaround today is to fully hardcode the tag format, which creates an obvious duplication with the specified format in version.json: if we end up changing the format on version.json, our GitHub workflow goes out of sync and would need to be updated separately.</issue_description>

<agent_instructions>Let's deliver on this request by adding a --what-if switch to the nbgv tag command. When specified, the tag will not be created, and the only text written to stdout should be the name of the tag.

If --what-if is used in a case where we would need to interrogate the user to pick commits, we should still write that out in an interactive way. The last line written would still be the name of the tag.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1265


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add feature to retrieve future tag name without creation Add --what-if switch to nbgv tag command to preview tag names Oct 15, 2025
Copilot finished work on behalf of AArnott October 15, 2025 18:33
Copilot AI requested a review from AArnott October 15, 2025 18:33
@AArnott AArnott added this to the v3.9 milestone Oct 15, 2025
@AArnott AArnott marked this pull request as ready for review October 15, 2025 18:55
@AArnott AArnott enabled auto-merge October 15, 2025 18:55
@AArnott AArnott added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 66144cf Oct 15, 2025
23 checks passed
@AArnott AArnott deleted the copilot/add-get-tag-name-feature branch October 15, 2025 19:32
This was referenced Nov 10, 2025
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.

[Feature] Provide a way to get the tag name for the current context without actually creating the tag

2 participants