mirror of
https://github.com/semver/semver.git
synced 2026-07-11 06:53:03 -05:00
[GH-ISSUE #465] How many hypens are you allowed? #1206
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 @elduddz on GitHub (Oct 4, 2018).
Original GitHub issue: https://github.com/semver/semver/issues/465
I am trying to get clarification on how many hyphens you can have in the prerelease tag?
I have noted wording in https://semver.org/spec/v2.0.0.html#spec-item-9
A pre-release version MAY be denoted by appending 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. Pre-release versions have a lower precedence than the associated normal version. A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
From this I have assumed you can have only one hyphen.
Someone then pointed me to a previous issue raised: https://github.com/semver/semver/issues/78#issuecomment-14981739
if you are allowed more than one hyphen, why is the wording hyphen and not hyphens? and there is nothing in the examples with more than 1 hyphen.
@klehelley commented on GitHub (Oct 5, 2018):
The first hyphen is not actually part of the pre-release part of the version identifier, but the separator between the X.Y.Z part and the pre-release part. The pre-release part can contain hyphens. The way I understand it, that means that when evaluated, version identifier
1.0.2-0.pre-prod.1-2+abcdewill be interpreted this way:1020(numeric)pre-prod(string)1-2(string)abcdeYou are right I think however to point out that to match the provided regex and the pluralization of "ASCII alphanumerics", the second instance of "hyphen" in the quoted text should probably be pluralized.
@jwdonahue commented on GitHub (Oct 7, 2018):
@elduddz, good catch! But the issue isn't why isn't it plural, the issue is that it's not plural. See #460 for a PR with links to related discussion on the actual regex that is proposed to be added to the FAQ. In the one or more of the related discussions you will find a largish test-data set that includes valid semver strings similar to 1.2.3----RC-SNAPSHOT.12.9.1--.12. We should update the spec to say something like:
It's worth fixing, would you like to issue PR to fix it for us? If not, we'll leave this thread open until someone has time to deal with it.
Thank you!
@fourpastmidnight commented on GitHub (Oct 12, 2018):
Yes, if you read this, this is a valid version number:
1.0.0--.1And so is this:1.0.0----.@jwdonahue commented on GitHub (Oct 12, 2018):
@elduddz, I have pull-request pending in #466, please close this issue at your earliest possible convenience. Any related comments can be directed to the PR discussion thread.