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

SemVerHelper.PreRelease.TryParse cannot parse valid nuget pre-release identifiers #522

Closed
HCanber opened this issue Aug 19, 2014 · 4 comments

Comments

@HCanber
Copy link

HCanber commented Aug 19, 2014

The current SemVerHelper.PreRelese parser isn't following the current SemVer spec.
For example this is a valid prerelease string Beta.7.z.92 that the PreRelease has problems with.

This is fine because nuget does not support those either. :)

The Nuget prerelease spec says

If there's a string there, it's a prerelease version.
The prerelease versions are given precedence in alphabetical order (well technically lexicographic ASCII sort order).

Since SemVerHelper:PreRelease.TryParse expects a string followed by an int the following strings cannot be parsed, but they should as nuget will accept them:

  • dev20140819130924 (the digits are the date + time in ISO8601) order as the number is to large for an int. This is something I really need!
  • dev-2014-08-19T130924

I suggest you remove the int-parsing and just use the regex [0-9A-Za-z-]+ as SemVer spec defines. The spec says that prerelease with only digits should be compared numerically, and identifiers with letters or hyphens should be compared in ascii order. However Nuget specifies ascii sort order so just treating it as a string will be fine.

@forki
Copy link
Member

forki commented Aug 19, 2014

Nice analysis. I'm currently on vacation. Are you interested in sending a pull request for this?

@HCanber
Copy link
Author

HCanber commented Aug 19, 2014

I'm guessing this is a trivial fix for someone that knows F#. Unfortunately I don't. :(

weismat added a commit to weismat/FAKE that referenced this issue Aug 25, 2014
SemVerHelper Make Number string instead of int
Change Regex accordingly
weismat added a commit to weismat/FAKE that referenced this issue Aug 25, 2014
Changes for fsprojects#522: SemVerHelper.PreRelease.TryParse cannot parse valid nuget pre-release identifiers
Make number string option
Change regex accordingly.
No tests found:
Tested via fsi.exe:
val x : PreRelease option = Some {Origin = "dev20140819130924";
                                  Name = "dev";
                                  Number = Some "20140819130924";}

> let x = PreRelease.TryParse("dev-2014-08-19T130924");;

val x : PreRelease option = Some {Origin = "dev-2014-08-19T130924";
                                  Name = "dev";
                                  Number = Some "-2014-08-19T130924";}
@weismat
Copy link

weismat commented Aug 26, 2014

I have problems to map the members of PreRelease to the naming inside the spec.
The spec does not mention "origin".
Furthermore I think that the code is currently not handling multiple elements/dots inside the build metadata (as Build is mapped to the hardcoded 3rd instead of the last element).

weismat added a commit to weismat/FAKE that referenced this issue Nov 14, 2014
This reverts commit ad5c8be.
@dsyme
Copy link
Collaborator

dsyme commented Oct 1, 2016

Fixed in #1325

@dsyme dsyme closed this as completed Oct 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants