-
-
Couldn't load subscription status.
- Fork 177
Add --what-if option to prepare-release command for simulating version changes #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: AArnott <[email protected]>
Co-authored-by: AArnott <[email protected]>
| /// <returns> | ||
| /// A <see cref="ReleaseInfo"/> object containing information about the simulated release. | ||
| /// </returns> | ||
| public ReleaseInfo SimulatePrepareRelease(string projectDirectory, string releaseUnstableTag = null, Version nextVersion = null, VersionOptions.ReleaseVersionIncrement? versionIncrement = null, ReleaseManagerOutputMode outputMode = default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Instead of creating a whole new method that duplicates a bunch of logic and needs to be kept in sync between the two methods, please add a parameter to the existing PrepareRelease method, or have these two methods call a 3rd private helper method that has most of the logic and takes a whatIf switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've refactored the code to use a single PrepareRelease method with a whatIf parameter instead of duplicating logic in a separate SimulatePrepareRelease method. The implementation now uses a private PrepareReleaseCore helper method that contains all the shared logic and takes the whatIf parameter to determine whether to actually make git changes or just simulate them. This eliminates code duplication and keeps the two code paths in sync automatically. Fixed in commit 28d04ed.
src/nbgv/Program.cs
Outdated
| { | ||
| Description = "A custom message to use for the commit that changes the version number. May include {0} for the version number. If not specified, the default is \"Set version to '{0}'\".", | ||
| }; | ||
| var whatIf = new Option<bool>("--what-if", Array.Empty<string>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Let's drop the optional Array.Empty argument for the string[] parameter, both here and elsewhere in the file where it's used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've removed all the optional Array.Empty<string>() arguments from the Option declarations throughout the Program.cs file, including the ones for metadata, versionIncrement, unformattedCommitMessage, whatIf, skipCloudBuildNumber, source, and define options. Fixed in commit 28d04ed.
Co-authored-by: AArnott <[email protected]>
…nd remove Array.Empty arguments Co-authored-by: AArnott <[email protected]>
This PR adds a
--what-ifoption to thenbgv prepare-releasecommand 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-ifflag enables users to preview the results of a prepare-release operation before committing to it:Implementation
--what-ifoption: Added to the prepare-release command with appropriate help textSimulatePrepareReleasemethod: New method inReleaseManagerthat performs all the same validation and version calculation logic as the regularPrepareReleasemethod, but without making any git changesExample outputs
Text format:
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.