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

Semver parse fix to handle prereleases and build parts #1325

Merged
merged 5 commits into from
Aug 22, 2016

Conversation

baronfel
Copy link
Contributor

@baronfel baronfel commented Jul 21, 2016

Fixes #1324 by rewriting the prerelease and build parsing sections to adhere to spec, while maintaining the Origin, Name, and Number portions of the current logic.

This has implications for existing uses of this code, because the prior code wasn't up to spec. This code implements proper comparison for prerelease identifiers, and now discards the build portion in order to compare.

Thoughts? We hit this when a git sha that we used for stamping prerelease information on a nupkg started with a number and the semver info helper broke :(

Also touches #522 around build information.

@baronfel
Copy link
Contributor Author

Also addresses #1154

@forki
Copy link
Member

forki commented Jul 22, 2016

do we need to do the same in paket?

@baronfel
Copy link
Contributor Author

Yeah, but the problem there is compounded by the fact that there are two, slightly different implementations of SemVer there already split between the bootstrapper and Paket.Core.

Is it worth splitting this out somehow and/or paket file including the source file over there?

@@ -132,7 +132,7 @@ public class when_parsing_many_pre_release_versions
#### 2.0.0-alpha001 - December 15 2013
* A";
static readonly ReleaseNotesHelper.ReleaseNotes expected =
ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc007", null, new[] { "A" }.ToFSharpList());
ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc2", null, new[] { "A" }.ToFSharpList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change because the comparison logic in the spec changed. rc007 is now less than rc2, so the expected output for the given release notes data had to change to take the improved comparison rules into account.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's breaking in fake. Not sure if we really want that.

On Jul 24, 2016 6:56 PM, "Chester Husk III" [email protected]
wrote:

In src/test/Test.FAKECore/ReleaseNotesSpecs.cs
#1325 (comment):

@@ -132,7 +132,7 @@ public class when_parsing_many_pre_release_versions

2.0.0-alpha001 - December 15 2013

  • A";
    static readonly ReleaseNotesHelper.ReleaseNotes expected =
    •        ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc007", null, new[] { "A" }.ToFSharpList());
      
    •        ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc2", null, new[] { "A" }.ToFSharpList());
      

I made this change because the comparison logic in the spec changed. rc007
is now less than rc2, so the expected output for the given release notes
data had to change to take the improved comparison rules into account.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/fsharp/FAKE/pull/1325/files/799b4be354b7eb8da836eec694fe7385d43411d7#r71991697,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNHkwzbdlZ2itA60z_q8eYrUxUSdNks5qY5k1gaJpZM4JSHRJ
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current logic is wrong, though. Part of the reason I chafed working with nuget was because they implemented almost-sorta-but-not-really-semver, so none of the existing libraries worked. Do we want to do the same? Besides, if people depend on that sorting, they can either

  1. use a prerelease of the form rc.{increment}, where increment is a number and thus compared numerically, or
  2. use a prerelease of the form rc{padding}{number}, and be consistent, so rc007 compared to rc002,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is usually the existing packages. But maybe this is less of a
problem now. It was a huge problem couple of years ago before we starter
with paket

On Jul 24, 2016 7:01 PM, "Chester Husk III" [email protected]
wrote:

In src/test/Test.FAKECore/ReleaseNotesSpecs.cs
#1325 (comment):

@@ -132,7 +132,7 @@ public class when_parsing_many_pre_release_versions

2.0.0-alpha001 - December 15 2013

  • A";
    static readonly ReleaseNotesHelper.ReleaseNotes expected =
    •        ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc007", null, new[] { "A" }.ToFSharpList());
      
    •        ReleaseNotesHelper.ReleaseNotes.New("2.0.0", "2.0.0-rc2", null, new[] { "A" }.ToFSharpList());
      

Current logic is wrong, though. Part of the reason I chafed working with
nuget was because they implemented almost-sorta-but-not-really-semver, so
none of the existing libraries worked. Do we want to do the same? Besides,
if people depend on that sorting, they can either

  1. use a prerelease of the form rc.{increment}, where increment is a
    number and thus compared numerically, or
  2. use a prerelease of the form rc{padding}{number}, and be
    consistent, so rc007 compared to rc002,


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/fsharp/FAKE/pull/1325/files/799b4be354b7eb8da836eec694fe7385d43411d7#r71991787,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNEBbyq4YdgDhIJmJc4cPCec9CYrUks5qY5pigaJpZM4JSHRJ
.

@forki
Copy link
Member

forki commented Jul 24, 2016

yes I think I tried to split it out into a separate file but didn't suceed

@baronfel
Copy link
Contributor Author

re: splitting this out - it's in a separate file with no non-framework dependencies, so we could just paket include it in paket. This could be an issue, though, as paket exposes SemVerInfo publically so I think we'd get name collisions, and Fake's SemVerInfo wouldn't be the same as Paket's.

@baronfel
Copy link
Contributor Author

I think we want to have a 'correct' implementation of SemVer in Fake and Paket for internal use for sure. Then, especially in the nuget-related areas of Fake and Paket, if we need to have a stripped down version of Semver that's up to nuget spec but not SemVer proper, we can have mapping functions that assert the invariants.

@baronfel
Copy link
Contributor Author

Alternatively, we could just use kolectiv's SemVer.net (FParsec parser + nice tests) in both places? https://github.com/xyncro/semver.net. That would handle the issue with sharing types around. But then we have even more back-compat issues.

@baronfel
Copy link
Contributor Author

baronfel commented Aug 5, 2016

It would be very easy to leave the current implementation, mark it as obsolete, and include this new code as a 'SemVer2Helper' or something like that. But Paket is the real sticking point. Do you have any guidance here as to what you prefer?

@forki
Copy link
Member

forki commented Aug 9, 2016

good question. I still don't know which packages would be affected

@baronfel
Copy link
Contributor Author

hey, good news! Nuget client has started supporting SemVer 2.0 as of 3.5.0-rc1! https://emgarten.com/2016/08/09/semver-2-0-0-with-nuget-3-5-0-rc1/

So maybe this gives us some cover to move forward?

@forki
Copy link
Member

forki commented Aug 22, 2016

ok let's try it.

@forki forki merged commit da55f18 into fsprojects:master Aug 22, 2016
@forki
Copy link
Member

forki commented Aug 22, 2016

thanks!

@baronfel
Copy link
Contributor Author

Want me to mirror these changes to Paket?

On Mon, Aug 22, 2016, 03:19 Steffen Forkmann [email protected]
wrote:

thanks!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1325 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAjCGwuyOeRCANPa-rF-YyPDdrQNYg03ks5qiVupgaJpZM4JSHRJ
.

@forki
Copy link
Member

forki commented Aug 22, 2016

yes. that would be awesome

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

Successfully merging this pull request may close these issues.

2 participants