Allow parsing not-quite-semver versions #25
Closed
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.
Ref. Lenient parsing of not-quite-semver versions dtolnay/semver#142
Change the behaviour for parsing not-quite-semver versions, specifically when there is only a major section, and when there is no patch section. Rather than error out, we check if we are at the end of the string. If so, then we return the version with all the information we know so far and zero out the rest. If we are not at the end of the string then we error out with the same error message.
The version formats this PR addresses are:
parse("1")
which hasmajor=1; minor=0; patch=0
parse("1.2")
which hasmajor=1; minor=2; patch=0
parse("1.2-beta")
which hasmajor=1; minor=2; patch=0; pre=beta
parse("1.2+build")
which hasmajor=1; minor=2; patch=0; build=build