[GH-ISSUE #465] How many hypens are you allowed? #7314

Closed
opened 2026-06-20 17:17:21 -05:00 by GiteaMirror · 4 comments
Owner

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.

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.
Author
Owner

@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+abcde will be interpreted this way:

  • X.Y.Z part:
    • MAJOR: 1
    • MINOR: 0
    • PATCH: 2
  • Pre-release part:
    • 1st identifier: 0 (numeric)
    • 2nd identifier: pre-prod (string)
    • 3rd identifier: 1-2 (string)
  • Build metadata part: abcde

You 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.

<!-- gh-comment-id:427282863 --> @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+abcde` will be interpreted this way: * X.Y.Z part: * MAJOR: `1` * MINOR: `0` * PATCH: `2` * Pre-release part: * 1st identifier: `0` (numeric) * 2nd identifier: `pre-prod` (string) * 3rd identifier: `1-2` (string) * Build metadata part: `abcde` You 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.
Author
Owner

@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:

MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].

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!

<!-- gh-comment-id:427625585 --> @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: > MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-]. 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!
Author
Owner

@fourpastmidnight commented on GitHub (Oct 12, 2018):

Yes, if you read this, this is a valid version number: 1.0.0--.1 And so is this: 1.0.0----.

<!-- gh-comment-id:429388812 --> @fourpastmidnight commented on GitHub (Oct 12, 2018): Yes, if you read this, this is a valid version number: `1.0.0--.1` And so is this: `1.0.0----`.
Author
Owner

@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.

<!-- gh-comment-id:429479018 --> @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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#7314