mirror of
https://github.com/semver/semver.git
synced 2026-07-11 05:12:48 -05:00
[GH-ISSUE #561] Improve item 11 #4652
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tomschr on GitHub (Apr 18, 2020).
Original GitHub issue: https://github.com/semver/semver/issues/561
Situation
While working on a semver related library, I've had to read item 11 of the specification for clarification. It states (emphasized by me):
The ellipsis contains the following rules (cited from the spec, but reformatted for better readability):
Question
I'm trying to understand how the above rules are applied to a specific prerelease. How does the spec compare when one of the prereleases has a dot and the other don't? For example:
(Keep in mind the dot in
beta.2and the absence inbeta1).From my understanding, the spec has a gap here. It doesn't specify if such a dot is taken into account or not (or it is and I misread it).
IMHO, most people would assume that the above expression would evaluate to true. My emphasized phrase phrase seems not to take into account if a dot itself matters. Is my observation correct or is my understanding wrong?
Proposal
IMHO, the specification is not clear enough on this particular example. I would propose to extend item 11 with:
Currently, the example in the spec looks like this:
Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
I would propose to extend it to clarify the order of a prerelease without a dot:
Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta3 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.
If you don't agree, then please try to reformat item 11. It's a long block of text and it would help to understand if you introduce a list as I've shown in the beginning. 😉
Thanks! Hope it does make sense. 😉
@klehelley commented on GitHub (Apr 20, 2020):
What about identifiers that end with numbers that should not be evaluated as if a dot was there?
In your example, things are IMO pretty clear:
1.0.0-beta1:1.0.0-beta.2:Looking at the first difference between these two version strings, we have the first pre-release identifiers:
beta<beta1. The comparison can stop here, and as a consequence the precedence rules state that1.0.0-beta.2<1.0.0-beta1.If this result is not what is expected, the fault here is on the project maintainer being inconsistent in naming versions. The spec seems pretty clear to me in the way a SemVer string is structured and how to compare two of them. I do agree however that rule 11 is a bit of a mouthful, presented in a single paragraph on the current spec.
@tomschr commented on GitHub (Apr 20, 2020):
@klehelley Thanks Kévin for your detailed answer! Much appreciated. 👍
After your explanation and rereading the paragraph, I understand now how this is meant. I can accept it. 👍
However, I still think, the wording can be improved. Maybe it's my limited understanding of the English language, but not all are native speakers. 😉 We all have different (language) backgrounds. Especially for a specification, clarity is of uttermost importance. That's why I'm so picky. 😆
Sure, there are translations. Depending on who translated it, it can introduce a different meaning. In my case, I try to read the original spec as much as I can although there is a translation available for my language.
Improving item 11 would not only help the original English spec, but all translations would benefit from this.
May I suggest to use my suggestion from above? You don't have to change the wording, it would only introduce a list and the items would be the conditions. I'm sure this would make the whole item 11 a lot more accessible.
Would that be an approach to pursue?
@jwdonahue commented on GitHub (Jun 9, 2020):
I think a state machine diagram would be most appropriate. Any shuffling of the text is always going to create new difficulties for somebody, while possibly clearing things up for someone else. I think one goal of the spec is to keep the verbiage as terse as possible, while still providing enough clarity that someone who studies the spec and thinks about its implications, is usually going to get it right.
Adding a diagram for the sorting algorithm that is implicitly specified by the spec, would beat any combination of examples you could list in the text.