Skip to content

Updating build number mechanics - #61

Closed
loudej wants to merge 1 commit into
semver:masterfrom
loudej:master
Closed

loudej wants to merge 1 commit into
semver:masterfrom
loudej:master

Conversation

@loudej

@loudej loudej commented Jan 7, 2013

Copy link
Copy Markdown

Enables pre-release and build number to be processed with exactly the
same algorithm. Clarifies the usage and semantics of build numbers as
entirely different and subordinate to patch and pre-release.

Enables pre-release and build number to be processed with exactly the
same algorithm. Clarifies the usage and semantics of build numbers as
entirely different and subordinate to patch and pre-release.
@haacked

haacked commented Jan 8, 2013

Copy link
Copy Markdown
Contributor

Next week I'm in SF and I want to chat with @mojombo briefly before I make any final decisions. But I want to make the case for one more option.

Right now, I feel like no matter which option we choose, someone will be unhappy. So be it. Shit happens.

However, there's one option that I feel provides the most benefit and keeps things simple. A couple of folks were opposed to it, but I don't fully understand the objection.

Let's focus on some of the problems we want to solve:

  1. Producers of packages want to be able to add a build designation to a package version without violating SemVer.
  2. Producers of packages don't want the extra pain of having to strip the build designation from packages when they ship it.
  3. If two builds are in the feed, there needs to be a way to determine precedence.
  4. Compatibility concerns with existing implementations of RC2.

Here's what I propose. The build designation is purely metadata for producers of a package. It does not figure into SemVer version comparisons or in the identity of the package. It is effectively a "comment" analogous to code comments:

sum(10,20) # Some comment

int x = 4; // this is a comment too

1.0.0+build001.can.be.anything

Everything after (and including) the "+" sign is ignored as far as the SemVer specification is concerned. The benefit is that producers of packages can stamp their build info into the package version without having to strip it later when they publish the package to a SemVer compliant package manager.

In other words, this solves 1 and 2, but not 3.

Under this proposal, #3 is in the province of a given implementation. Going back to the code comment analogy, it's similar to how TomDoc does more with specially formatted Ruby comments or you can add custom documentation elements to C# documentation comments.

So if NuGet wants to sort it one way, but OpenWrap wants to sort it another, and Ruby Gems wants to ignore it altogether, so be it. SemVer doesn't care. As far as SemVer is concerned, the build part is ignored.

What's the downside?

Well one downside I've heard is leaving ordering unspecified is a nightmare. Well this doesn't do that. As far as SemVer is concerned 1.0.0 and 1.0.0+build1 are the same versions.

The other argument I've heard against this is that you can't then aggregate different package feeds because the ordering will be nondeterminate. But we're not actually introducing a problem here. Today, I could aggregate two feeds with "Foo 1.0.0" package only to find out that they aren't the same package. Even with build numbers, it's not guaranteed that both feeds are following the same build numbering strategy in the first place so that you'd get the "correct" sort, whatever that means.

If I'm missing something important, please let me know why this would not be satisfactory. I think it's certainly better than arbitrarily picking one sort over the other and better than striking the build number altogether. It certainly doesn't make the situation any worse than SemVer 1.0 and allows NuGet and OpenWrap to solve their specific needs with builds working towards a release.

@loudej

loudej commented Jan 8, 2013

Copy link
Copy Markdown
Author

I'm good with that. Was very close to suggesting similar myself - actually that any invalid character could mark the beginning of metadata and be part of it.

Even if the only semver defined operation for metadata is equality it still works to provide uniqueness (1.0.0+42 != 1.0.0+43 != 1.0.0 != 1.0.0a != 1.0.0~2 because "+42" != "+43" != "" != "a" != "~2") so you can easily use it for cache-busting or referencing specific bits from a build server feed.

@serialseb

Copy link
Copy Markdown

I can live with that, leave the processing undefined. Lou's point about invalid characters is also interesting and a section should be added to provide for extensibility in future versions (something lacking from the original spec). I could add a pull request for that this weekend (aka any invalid character starts an ignored block and the block is delimited by either finding an existing separator character recognized by the spec or the end of the string). This would leave the usage of ~ open for usage in future specs shall it be needed. Would people find this useful?

@serialseb

Copy link
Copy Markdown

Note that the text ought to specify that build is defined as dot-separated identifiers but the meaning of it is undefined as far as semver is concerned. In RFC parlance, "Consumers SHOULD NOT rely on the build information when taking dependencies on packages" as opposed to a MUST NOT (again because we convert everything to the semver syntax and there are extreme cases where consumers need a joker card to save themselves from producers that used the build not according to the spec. Relying on producers doing the right thing for a system not to stop functioning does not work in practice (and is why we reluctantly added special dependency operators for taking dependencies on builds, although we do make it extra difficult to use those and only discuss those at the end of a man page somewhere hidden).

@haacked

haacked commented Jan 8, 2013

Copy link
Copy Markdown
Contributor

@loudej @serialseb my only reservation about extending it to "any" invalid character is it limits future extensions to SemVer. At this point, I can't think of any such extensions.

Perhaps we can define a set of "reserved" characters that would not be included in the "invalid" set just in case. I like where this is going though.

@serialseb if you want to send a PR with your thoughts, that'd be great. As you pointed out in the issue thread, it's a much preferred way of having this discussion than endless discussions in an issue. 👍

@haacked haacked mentioned this pull request Jan 8, 2013
@haacked

haacked commented Jan 8, 2013

Copy link
Copy Markdown
Contributor

Note that the text ought to specify that build is defined as dot-separated identifiers

@serialseb why? Should we instead just provide a set of allowed characters to make it clear when a version build ends?

We definitely want to avoid the following:

1.0.0+where does this version end?

I'm not disagreeing with you, but I want to make sure we provide a rationale. I think it does make sense that even though it's similar to a comment, it's not an actual comment and still has restrictions.

@serialseb

Copy link
Copy Markdown

Without it you can't make the extensibility on unknown characters feasible. If you allow anything, then it becomes the extension block, which means package managers may take on a dependency on an undefined format that now will have to stay as an opaque string forever.

Say tomorrow you want to allow for platform identifiers as part of the version identifier (or a debug version or whatever it is you want to do that affects package identity): if the build block is known, any start of an unknown character starts an extension block until such a recognised character is found. Tomorrow you add ^ as a valid separator, semver2 can still process that block as unknown, semver3 can read what it means and do useful things with it.

I don't think with such a system you need to have reserved characters, as any character not allowed in version identifiers (as used in pre) automatically starts an extension block.
On 8 Jan 2013, at 16:26, Phil Haack <[email protected]mailto:[email protected]>
wrote:

@loudejhttps://github.com/loudej @serialsebhttps://github.com/serialseb my only reservation about extending it to "any" invalid character is it limits future extensions to SemVer. At this point, I can't think of any such extensions.

Perhaps we can define a set of "reserved" characters that would not be included in the "invalid" set just in case. I like where this is going though.

@serialsebhttps://github.com/serialseb if you want to send a PR with your thoughts, that'd be great. As you pointed out in the issue thread, it's a much preferred way of having this discussion than endless discussions in an issue. [:thumbsup:]

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/61#issuecomment-12004210.

@haacked

haacked commented Jan 10, 2013

Copy link
Copy Markdown
Contributor

@serialseb ah very good point about new extensions to SemVer 3 would still be valid SemVer 2 syntax (though undefined). Great! I'll send a new PR soon with the language unless you'd be willing to write this up and send a PR. :)

@loudej

loudej commented Jan 10, 2013

Copy link
Copy Markdown
Author

Great, I think this should work well. Only concern is if metadata is scanned for known delimiters then adding something to semver 3 would be incompat if value characters collide. If we assume semver will always declare semantic fields that precede metadata field, then you only have to worry about collisions with metadata leading characters, not all value characters

Imagine semver 2 with custom '+' metadata: 1.0.0+3!4 1.0.0+3!5

note '+' happens to allow '!' as a value char

Imagine semver 3 adds a hotfix '!' int: 1.0.0!2

The custom '+' metadata still okay: 1.0.0+3!4

And even works combined with hotfix '!': 1.0.0!2+3!4

It would also make processing metadata, comparing or storing a semver as component fields, and reconstructing ids out of fields a lot easier if you can assume there is one trailing metadata value.

@loudej

loudej commented Jan 10, 2013

Copy link
Copy Markdown
Author

That said - that particular detail can be sorted out if and when semver 3 happens. The only question for semver 2 wrt deep scanning for delimiters is: "can pre tag come after metadata?"

in other words should 1.0.0+6-foo be treated the same as 1.0.0-foo+6? If yes, then you must scan metadata for semver delimited. If no, then metadata is an opaque "+6-foo". I'd vote no...

@jeffhandley

Copy link
Copy Markdown
Contributor

Any further updates here?

I too am fine with the SemVer spec simply defining that different build numbers simply mean inequality. The cache busting concept is gold.

I think we're best off denoting one character as "everything behind this is ignored." The # character seems logical to me. I would like to reiterate @loudej's point about new versions' features colliding with old comments--we need a way to denote comments.

And I agree that we need to define the order in which parts can exist and -pre must come first.

1.0.0-foo+6#bar

@haacked

haacked commented Mar 1, 2013

Copy link
Copy Markdown
Contributor

Agreed, how about we state that the metadata segment must be the last part. As soon as you see it, everything after is ignored.

@jeffhandley

Copy link
Copy Markdown
Contributor

Yeah, we must force that. Otherwise, any special characters in the metadata segment would be vulnerable to future use.

Comment thread semver.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So I thought we all agreed to remove the build precedence altogether and move to a model where the "build version" is metadata. Can you update this pull request to reflect our latest thinking? I wonder if we should call it something other than "build version" to avoid confusion. Like "build metadata" or "build identifier".

@haacked

haacked commented Mar 5, 2013

Copy link
Copy Markdown
Contributor

@jeffhandley want to take a crack updating this PR with the wording that reflects the recent decisions we made?

@jeffhandley

Copy link
Copy Markdown
Contributor

Yes, I will as soon as I can.

@haacked

haacked commented Mar 13, 2013

Copy link
Copy Markdown
Contributor

I think it's safe to close this one in favor of #70.

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.

4 participants