Skip to content
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

Allow disabling "g" prefix for commit hash in version number #260

Closed
akoeplinger opened this issue Nov 26, 2018 · 8 comments · Fixed by #269
Closed

Allow disabling "g" prefix for commit hash in version number #260

akoeplinger opened this issue Nov 26, 2018 · 8 comments · Fixed by #269
Assignees
Milestone

Comments

@akoeplinger
Copy link
Member

I've had multiple folks (including myself) be confused about the g in front of the commit sha of a version number like 16.0.40-preview+ge6c3a1f9e4.

You don't immediately realize without knowing this convention that the g isn't part of the sha and wonder why you can't find the commit. Is there a reason for the prefix or could there be an option to turn it off?

@AArnott
Copy link
Collaborator

AArnott commented Nov 26, 2018

It stands for git, and provides a more deterministic way to ascertain that what follows is the commit ID. I don't remember where it came from (I didn't invent the convention).

I've heard this feedback several times though, and I sympathize with the inconvenience of not being able to just double-click to select the "word" and paste it somewhere else without having to trim off the leading g.

I'm not sure anyone even likes the leading g (as folks don't tend to reinforce behavior that they like), so while an option to remove it seems perfectly reasonable, it's worth considering simply removing it entirely, or at least making the option default to removal.

I'm planning some breaking changes for a 3.0 version, and changing this behavior (or at least the default) would be well-placed for the 3.0 version, I think. And perhaps we can add the option in 2.3, but change its default in 3.0.

@AArnott
Copy link
Collaborator

AArnott commented Nov 26, 2018

Anyone reading this issue should please vote up or down on the original issue description. I'm interested in comparing the vote count.

@AArnott AArnott added this to the 2.3 milestone Nov 26, 2018
@AArnott AArnott self-assigned this Dec 7, 2018
AArnott added a commit that referenced this issue Dec 8, 2018
AArnott added a commit that referenced this issue Dec 8, 2018
@AArnott
Copy link
Collaborator

AArnott commented Dec 9, 2018

So... now I know why the g prefix is there. Without it, if the commit id happens to start with a number, nuget produces warnings:

This works great (when the commit starts with a letter):

Successfully created package '/root/bin/Debug/root.42.42.4-f92b4f1cbd.nupkg'.

But when the commit starts with a number:

Successfully created package '/root/bin/Debug/root.42.42.3-7d637a3dc6.nupkg'.
/usr/share/dotnet/sdk/2.1.403/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(199,5): warning NU5105: The package version '42.42.3-7d637a3dc6' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter. This message can be ignored if the package is not intended for older clients. [/root/root.csproj]

So, that stinks.

I could still make it an option, or make the g appear in only certain contexts and not others, but I'm worried it will be confusing/frustrating if the g appears in some places but not others since folks will have an even harder time predicting and understanding when/where it appears.

@AArnott
Copy link
Collaborator

AArnott commented Dec 9, 2018

I think the approach to fix this should be that we remove the g whenever the version.json file has opted into semver 2 for nuget packages. Or in other words, we use the g only for nuget package versions, and only when using semver 1 rules (which is the default).

@akoeplinger
Copy link
Member Author

akoeplinger commented Dec 9, 2018

@AArnott how about we replace the g with git-? That should make it clearer that the following is a git commit sha, e.g. root.42.42.4-git-f92b4f1cbd.nupkg

This should still be compliant with SemVer1 rules.

@gitfool
Copy link

gitfool commented Dec 9, 2018

I would prefer a g prefix, when enabled, since it’s a “standard” convention after all. For semver 2, it would be nice to drop the prefix, but then I’m now used to seeing it everywhere, e.g. msbuild output, so I guess ultimately it should be configurable?

AArnott added a commit that referenced this issue Dec 9, 2018
This removes `g` basically everywhere except for semver 1.0 compliant NuGet package versions, since older NuGet clients can't handle -prerelease tags that start with a digit (which some commit IDs do). For these, we still prefix the `g` as the convention to ensure that the prerelease tag starts with a letter.

Fixes #260
@nosalan
Copy link

nosalan commented Dec 28, 2023

Is this stil disableable?
I tried setting these but still get the g prefix.

  "gitCommitIdPrefix": "",
  "nugetPackageVersion": {
    "semVer": "2"
  },

I'm using cli to get the version: nbgv get-version -v SemVer2

@AArnott
Copy link
Collaborator

AArnott commented Dec 29, 2023

No @nosalan, the option to remove this was reverted. See earlier discussion for the problems that removing the prefix introduces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants