-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
When does patch version get reset to 0 or 1? #1117
Comments
What you describe isn't the default behavior, because that is discouraged behavior. Doing that would mean you're building the same package version for multiple distinct versions of your source code. That leads to package cache poisoning, where someone who already had v4.3.1 from your main branch in their package cache cannot consume v4.3.1 from your release branch until they realize they have to delete the old 4.3.1 package from their cache so that nuget restore brings down the new one. So while you can do what you want (by setting And FWIW, I've never heard a customer complain about 4.3.1409 being released instead of 4.3.0 or 4.3.1. A very few developers of the software itself (such as yourself) feel a bit ruffled at first when they discover this behavior, but I encourage you to consider giving up the need to release a .0 version. I haven't in many years... and no user has even mentioned that they noticed. |
We never have the issues that you refer to because our main branch is always labeled as being a prerelease, which includes beta/alpha and the commit id. So, never causes two builds to have the same version. Release branches under Also, a lot of people make the claim |
That's good, but it leaves another problem. Per sem-ver rules, { "version": "1.2-alpha.{height}" } This way, you'll build You make a fine point about the KISS principle. Just keep in mind even if the behavior you're asking for was automatic (that the patch version restarted at 0), you'd still get patch versions that are not necessarily consecutive, because you may merge several changes into your release branch between releases, and NB.GV counts commits for the version height. If you're going for the full control approach where you definitely want to start at 0 and definitely want consecutive numbering, then you can set the 3rd integer in your version.json explicitly and increment it manually. You'll still get some NB.GV benefits even in that configuration, because assembly version stamps can still include the version height (as the 4th integer) and the git commit ID itself is still burned into certain binary files by default. |
We do that, we set the height after the prerelease like in your example. This was the only way we could get npm to see the next prerelease as an update to a npm package. We originally had it doing the OoB version stamping of As for the consecutive patch versions in release branches. When we need to make a patch to a release, we create a new branch from the release, work on patch, make a PR from patch branch back into release branch using squash merge. Causing all the commits from patch to be in one commit. Then we create a PR from patch branch into main, using standard marge that keeps commit history. Our main branch has all history from beginning of project, allowing to look for specific work or changes if needed. We would much rather not have to manually set the third digit, or manually apply the |
I don't see why not. I think the switch should fail if the version height had not already been moved into the prerelease tag as discussed above to avoid inadvertently reusing numbers or violating semver ordering. Would you care to author that pull request? |
Can you explain the constraint better, how do we test for that situation? I wouldn't mind authoring the addition. |
Sure. The condition is that For instance, this version.json would be allowed to use the {
"version": "1.2-beta.{height}"
} But using that switch would produce an error if the version.json file were just this: {
"version": "1.2-beta"
} Even the first file that would typically allow it, would disallow it if
because |
Ok, so do the following verifiactions
If both pass, set the |
and the CLI switch requesting this behavior is present.
I suppose, if that's the easiest way to go about it. But I suspect when you get into that code that you'll find a simpler way. For example just the presence of |
I can just do a simple check that version ends with |
@AArnott unrelated to this, but what would cause this? Running |
|
But what about the inconsistency of the build label not being what is printed in the task output from |
Oh that. It's probably that you're setting the build label to something else later in the build. In fact the default behavior of Nerdbank.GitVersioning is to set the cloud build number for every msbuild project's build, which in your case probably doesn't make sense and you should probably turn that off. |
When using this tool, and creating a release branch using
prepare-release
the patch number does not get reset back to 0 or 1 in the release branch. How do we get it to reset, so that releases start atv4.3.0
instead ofv4.3.1409
?The text was updated successfully, but these errors were encountered: