Skip to content

Address defects in SemVer comparison and parsing - #920

Merged
forki merged 1 commit into
fsprojects:masterfrom
baronfel:semver_prerelease_split
Jul 13, 2015
Merged

forki merged 1 commit into
fsprojects:masterfrom
baronfel:semver_prerelease_split

Conversation

@baronfel

@baronfel baronfel commented Jul 8, 2015

Copy link
Copy Markdown
Contributor

So this got kinda big, I'm sorry in advance.

At work, we made some nuget packages of the form Mozu.Component.Contracts.1.1.0-dev1507031354ci. That is the package Id, followed by an increasing major, minor, patch. Prereleases are of the form 'dev', then a YYMMDDHHmm timestamp, and then a few characters from the branch that created the package, in this case 'ci'.

This is fine from Nuget's point of view, because a prerelease term is any non-period string after a patch. This is also fine from SemVer 2.0, because a prerelease term is

a hyphen and a series of dot separated identifiers immediately following the patch version. 
Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. 
Identifiers MUST NOT be empty. 
Numeric identifiers MUST NOT include leading zeroes

However, Paket seems to be more strict than this, requiring that a prerelease term be only of the form (optional string part)(optional number part). So what happens is that the prerelease term is not parsed at all, which means a restore/install pulls an arbitrary Major.Minor.Patch version of the package Id in question from the server.

So for this pull request I redid the way that Paket parses and interprets prerelease identifiers, making a Prerelease record track a set of one or more PrereleaseSegments which can be either alphanumeric or numeric. This is important because the number of segments, as well as their types, has implications for comparisions according to section 11 of the SemVer 2.0 spec.

I've also addressed the build metadata portion of the spec. Based on my reading I see room for only one chunk of build metadata that isn't necessarily tied to whether or not a particular version string has a prerelease section or not. So I renamed that item. The build metadata is also not to be used in comparisions, so I removed it from consideration in the implementation of IComparable for the SemVerInfo class.

@forki

forki commented Jul 13, 2015

Copy link
Copy Markdown
Member

thx a lot

forki added a commit that referenced this pull request Jul 13, 2015
Address defects in SemVer comparison and parsing
@forki
forki merged commit 12c82b0 into fsprojects:master Jul 13, 2015
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