Open NiekRossenInfoSupport opened 1 month ago
Good question, and interesting scenario.
The reason versionHeightOffset
gets removed automatically is because the tool assumes it's a positive number, and the typical scenario for needing to set it to a positive number disappears when you increment the hard-coded version in the file.
I haven't heard much feedback nor feel that an initial patch of 0
is important, but if you want to keep doing that, I think a reasonable fix for this would be to update prepare-release
to only delete the versionHeightOffset
property if it has a non-negative value.
Would you like to submit the PR?
@AArnott Thanks for your reply. I took a look at the code but i can't seem to find where i should implement this. Can you point me in the right direction, where i should be making this change?
Here's the chain of events leading to resetting that property:
https://github.com/dotnet/Nerdbank.GitVersioning/blob/2b6b66ab90b84cd2689e8dcffc6060919d2b0255/src/nbgv/Program.cs#L787 https://github.com/dotnet/Nerdbank.GitVersioning/blob/2b6b66ab90b84cd2689e8dcffc6060919d2b0255/src/NerdBank.GitVersioning/ReleaseManager.cs#L208 https://github.com/dotnet/Nerdbank.GitVersioning/blob/2b6b66ab90b84cd2689e8dcffc6060919d2b0255/src/NerdBank.GitVersioning/ReleaseManager.cs#L283 https://github.com/dotnet/Nerdbank.GitVersioning/blob/2b6b66ab90b84cd2689e8dcffc6060919d2b0255/src/NerdBank.GitVersioning/SemanticVersion.cs#L284
Looking over it, I think the 3rd of these locations is the right place to modify the condition to special case -1
.
Description: I'm trying to apply the ReleaseFlow branching strategy to our project and using NerdBank.GitVersioning as our versioning tool. However, I'm encountering an issue where the versionHeightOffset property is removed from the version.json file after running the nbgv prepare-release command.
Current Configuration: Here's the version.json file I'm using:
Problem: After running the nbgv prepare-release command, the versionHeightOffset property is removed, resulting in the following version.json:
Objective: I want the version to be 1.2.0 after running the prepare-release command, instead of 1.2.1. I understand that the patch version 1 is based on the height, but I prefer it to be 0 after the release preparation. Also, I want the patch number to increase with each new commit to the release branch.
What I Tried: I know I can manually set the version property like "version": "1.3.0-SNAPSHOT.{height}", but this isn't ideal as I want the patch number to automatically increase with new commits to the release branch.
Question: How can I achieve the desired versioning behavior where the versionHeightOffset is maintained, and the version becomes 1.2.0 after running the prepare-release command?