Skip to content

Add --what-if option to prepare-release command for simulating version changes#1242

Merged
AArnott merged 7 commits into
mainfrom
copilot/fix-1019
Dec 20, 2025
Merged

Add --what-if option to prepare-release command for simulating version changes#1242
AArnott merged 7 commits into
mainfrom
copilot/fix-1019

Conversation

Copilot AI commented Aug 10, 2025

Copy link
Copy Markdown
Contributor

This PR adds a --what-if option to the nbgv prepare-release command that allows users to simulate the prepare-release operation and see what versions would be set without actually making any git changes.

What it does

The --what-if flag enables users to preview the results of a prepare-release operation before committing to it:

# See what versions would be set with default settings
nbgv prepare-release --what-if

# Preview with custom version increment
nbgv prepare-release --what-if --versionIncrement Major

# Get machine-readable JSON output
nbgv prepare-release --what-if --format json

Implementation

  • New --what-if option: Added to the prepare-release command with appropriate help text
  • SimulatePrepareRelease method: New method in ReleaseManager that performs all the same validation and version calculation logic as the regular PrepareRelease method, but without making any git changes
  • Consistent validation: The what-if mode uses the exact same validation logic, so errors and warnings are identical to the regular mode
  • Output formats: Supports both human-readable text output (with "What-if:" prefixes) and machine-readable JSON output
  • Comprehensive testing: Added 12 new tests covering various scenarios including version increments, prerelease tags, error conditions, and edge cases

Example outputs

Text format:

What-if: v3.8 branch would track v3.8 stabilization and release.
What-if: main branch would track v3.9-alpha development.

JSON format:

{
  "CurrentBranch": {
    "Name": "main",
    "Commit": "abc123...",
    "Version": "3.9-alpha"
  },
  "NewBranch": {
    "Name": "v3.8",
    "Commit": "abc123...",
    "Version": "3.8"
  }
}

This enhancement provides a safe way for users to understand the impact of prepare-release operations before executing them, addressing the need for predictable version management workflows.

Fixes #1019.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Comment thread src/NerdBank.GitVersioning/ReleaseManager.cs Outdated
Comment thread src/nbgv/Program.cs Outdated
Copilot AI changed the title [WIP] Simulate the future version Add --what-if option to prepare-release command for simulating version changes Aug 10, 2025
Copilot AI requested a review from AArnott August 10, 2025 19:31
…nd remove Array.Empty arguments

Co-authored-by: AArnott <[email protected]>
@AArnott AArnott marked this pull request as ready for review December 20, 2025 23:10
@AArnott AArnott enabled auto-merge December 20, 2025 23:11
This was referenced Jul 6, 2026
AngeloDotNet added a commit to AngeloDotNet/TinyDatabaseLocalization that referenced this pull request Jul 9, 2026
Updated
[Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning)
from 3.9.50 to 3.10.91.

<details>
<summary>Release notes</summary>

_Sourced from [Nerdbank.GitVersioning's
releases](https://github.com/dotnet/Nerdbank.GitVersioning/releases)._

## 3.10.91

## What's Changed

* Retry file operations on access denied errors by @​AArnott in
dotnet/Nerdbank.GitVersioning#1408


**Full Changelog**:
dotnet/Nerdbank.GitVersioning@v3.10.85...v3.10.91

## 3.10.85

## What's Changed

* Avoid writing server.json multiple times in a single pack by @​AArnott
in dotnet/Nerdbank.GitVersioning#1391

**Full Changelog**:
dotnet/Nerdbank.GitVersioning@v3.10.70...v3.10.85

## 3.10.70

## What's Changed

### Fixes

* Fix case insensitivity for the managed engine on git worktrees, and
implement for libgit2 by @​AArnott in
dotnet/Nerdbank.GitVersioning#1334
* Fix native heap corruption in GitPackIndexMappedReaderTests by
@​AArnott in dotnet/Nerdbank.GitVersioning#1360

### Enhancements

* Add prerelease property to inheriting version.json files by @​Copilot
in dotnet/Nerdbank.GitVersioning#1317
* Add NBGV_SetCloudBuildVersionVars property to disable cloud build
variable output by @​Copilot in
dotnet/Nerdbank.GitVersioning#1324
* Add --what-if option to prepare-release command for simulating version
changes by @​Copilot in
dotnet/Nerdbank.GitVersioning#1242
* Build nbgv CLI tool for .NET 9 and 10 by @​AArnott in
dotnet/Nerdbank.GitVersioning#1369


**Full Changelog**:
dotnet/Nerdbank.GitVersioning@v3.9.50...v3.10.70

## 3.10.44-alpha

## What's Changed

### Fixes

* Fix case insensitivity for the managed engine on git worktrees, and
implement for libgit2 by @​AArnott in
dotnet/Nerdbank.GitVersioning#1334

### Enhancements

* Add --what-if option to prepare-release command for simulating version
changes by @​Copilot in
dotnet/Nerdbank.GitVersioning#1242
* Add NBGV_SetCloudBuildVersionVars property to disable cloud build
variable output by @​Copilot in
dotnet/Nerdbank.GitVersioning#1324


### Dependency updates

* chore(deps): update dependency microsoft.build.locator to 1.11.2 by
@​renovate[bot] in
dotnet/Nerdbank.GitVersioning#1304
* chore(deps): update dotnet monorepo by @​renovate[bot] in
dotnet/Nerdbank.GitVersioning#1309
* Update dotnet monorepo by @​renovate[bot] in
dotnet/Nerdbank.GitVersioning#1338


**Full Changelog**:
dotnet/Nerdbank.GitVersioning@v3.10.8-alpha...v3.10.44-alpha

## 3.10.8-alpha

## What's Changed
* Add prerelease property to inheriting version.json files by @​Copilot
in dotnet/Nerdbank.GitVersioning#1317


**Full Changelog**:
dotnet/Nerdbank.GitVersioning@v3.9.50...v3.10.8-alpha

Commits viewable in [compare
view](dotnet/Nerdbank.GitVersioning@v3.9.50...v3.10.91).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Nerdbank.GitVersioning&package-manager=nuget&previous-version=3.9.50&new-version=3.10.91)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
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.

Simulate the future version

2 participants