-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Support versions with multiple "-" or "+" signs #478
Conversation
Currently if the version looks like `1.0.0-alpha-beta` it will be treated like it has a `PreRelease` part equal to `alpha`. The `PreRelease` part needs to be `alpha-beta` if you look at [semver spec](https://semver.org/#spec-item-9), that allows extra dash characters in the `PreRelease` part. The `BuildMetadata` part has a similar issue, with the plus sign., i. e. for `1.0.0+123+321` it will be computed to `123` and not `123+321`. Multiple pluses in version is not valid semver, and will probably cause an error when used with nuget. Despite that, it still feels like a similar issue should be fixed there. In sum, for version ``1.0.0-alpha-beta+123+321` this commit will set `MinVerPreRelease` to `alpha-beta` instead of current `alpha` and will set `MinVerBuildMetadata` to `123+321` instead of current `123`.
Note: I think it will work but haven't tested it, as I don't know how. Split takes |
@kojoru thanks for raising this PR. You're absolutely right about the pre-release identifiers! I can easily reproduce the problem: However, I'm not sure that build metadata is allowed to contain a
And if I try building a .NET project with build metadata containing a plus, the SDK returns an error:
|
@adamralph no, the build metadata is not allowed to contain a second plus indeed. It just felt to me like adding the same clause there will lead to less surprises over what's happening, and overall a better UI for what is a user error either way. |
@kojoru yes, I agree. After I wrote my comment, I thought about how MinVer constructs versions. If it finds a version tag it does the absolute minimum required to split it into major, minor, pre-release, and build metadata and does not do any kind of validation of SemVer rules such as "only ASCII alphanumerics and hyphens [0-9A-Za-z-]". Similarly it will just use separately specified build metadata, or a specified default pre-release phase as-is. Ultimately, the version is controlled by the user and it's up to them whether they want to adhere to SemVer or not. And it's also up to the SDK to decide what it allows and what it does not. There's no point trying to pre-empt that in MinVer, because those rules may change over time. When I get a moment, I'll add a test to this branch and then merge it. Thanks again! |
BTW, FWIW, this is a bug. I always intended it to work in the way you describe. I made a mistake by not limiting those two splits to two items only. This is the offending PR — https:/adamralph/minver/pull/166/files. The code which parses the tags does it correctly — Lines 141 to 142 in 80635da
This means that the version itself is correct. It is only the two output properties, |
@adamralph is there a way I can help with the tests? |
@kojoru thanks for offering. I'm currently in the middle of moving all the package tests out of the I hacked together a quick test locally on this branch and it works as you intended:
That's good enough for me to know that this works, so I'm going ahead and merging. |
@kojoru I've released this in 2.5.0-alpha.1, if you want to give it a try. |
Currently if the version looks like
1.0.0-alpha-beta
it will be treated like it has aPreRelease
part equal toalpha
.The
PreRelease
part needs to bealpha-beta
if you look at semver spec, that allows extra dash characters in thePreRelease
part.The
BuildMetadata
part has a similar issue, with the plus sign., i. e. for1.0.0+123+321
it will be computed to123
and not123+321
. Multiple pluses in version is not valid semver, and will probably cause an error when used with nuget. Despite that, it still feels like a similar issue should be fixed there.In sum, for version
1.0.0-alpha-beta+123+321
this commit will setMinVerPreRelease
toalpha-beta
instead of currentalpha
and will setMinVerBuildMetadata
to123+321
instead of current123
.