-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Why does git height start at 1 instead of 0? #102
Comments
It looks like I can get what I expect if I set
I think the issue is in int build = versionHeight.Value + (versionOptions?.BuildNumberOffset ?? 0);
...
return new Version(baseVersion.Major, baseVersion.Minor, build, revision); This would throw an exception any time there's a negative offset which has greater absolute value than the version height. It might make sense to either do: int build = versionHeight.Value + (versionOptions?.BuildNumberOffset ?? 0);
build = Math.Min(build, 0); which would guarantee a non-negative build number, or:
which would prevent the exception with an uncommitted |
Thanks for the feedback and the time you've taken to investigate your options and report the problem you found. I'll answer you at a high level below, after first responding to a couple points you make:
I think the point of that spec requirement is that when 1.2.3 is rev'd to 1.3, it shouldn't be 1.3.4 or 1.3.3, but 1.3.0 (the 3rd digit is reset). It doesn't require that you ship the 1.3.0 version precisely. In fact SemVer would insist (IMO) that if you think you'll ship 1.3.0 and then you realize in testing you need to patch something, you'll end up shipping 1.3.1 and never ship 1.3.0, and in such an event, someone pointing out that "you should have shipped 1.3.0 because of semver" would be missing one of the points of semver.
That's right. To answer your question about git height "starting" with 1 instead of 0, it's simply because I count commits, including the commit that set the version, so the minimum it could ever count is 1. This also has (IMO) a satisfying side effect of discouraging folks from getting hooked on shipping x.y.0 releases. Releasing x.y.0 when the revision number is git height is you could only achieve it by incrementing the version as the very last commit in a release. There are two problems with this:
Does that make sense? |
Thanks much for the detailed reply! I don't fully agree with all of your points, but I get where you're coming from and I appreciate your reasoning. I do think the issue with the build number that I reported above should be addressed in some way. I also think it would be good to tweak the graf on git height in the
(That last sentence isn't strictly needed, but I think it helps to be explicit about what's going on.) |
Good feedback. I'll fix both the docs and the exception thrown before closing this issue. |
Thanks! |
I'm curious about this. It looks like if I change the version in
version.json
to something like2.4
, and then commit and build, the version number I get is actually2.4.1
rather than2.4.0
. From the source, it looks like the package is reserving0
for a changed but uncommittedversion.json
, and always returning a positive (rather than non-negative) git height once the change is committed.There are some unfortunate implications here. First, it means that git height for this library is calculated in a different manner from the other libraries I've seen, in which the commit where the change was introduced is 0. (It's also different from what is implied by the
README
, and what I think a user would expect to be the case.) Second, it means that I can never release a version of my assembly which isx.y.0
. Among other things, I think this might run counter to the SemVer spec, which indicates that patch must be reset to 0 when minor or major increments.Can you clarify why the git height is calculated this way?
The text was updated successfully, but these errors were encountered: