Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SemVer has a bug introduced in 8781c0d:
What happens in the second case ("3.1.0-something") is that this regular
expression matches:
So the entire version string is replaced by nothing, and that is the
value that $v gets. All other cases (such as "3.1", or "3.1.0") don't
match, and so the replacement never happens.
This empty $v is then passed on to version->declare, which complains
that the version is required.
It seems the full regexp was added hoping to be a validation step for
strict semantic versions in declare() and parse(). Unfortunately, this
wasn't working (as explained above), and in fact, that is not the
desired behaviour for these functions. From the docs for declare():
"This is the most flexible way to declare versions. Consider using it to
normalize version strings." With that in mind, the input has to allow
"not normal" version strings.
This patch restores the old behaviour, fixing usage of declare() and
parse(). I'm not super comfortable with how parse() is supposed to work,
so I didn't add any tests for it. But I did add tests for declare().