Optionally be able to work with leading 'v'
See original GitHub issueCurrently
semver.parse_version_info("v0.1.0")
fails with
ValueError: v0.1.0 is not valid SemVer string
However the leading v
is not included in the semver spec (https://semver.org), but the master branch of semver/semver has the following faq section - https://github.com/semver/semver/blob/master/semver.md#is-v123-a-semantic-version :
Is “v1.2.3” a semantic version? No, “v1.2.3” is not a semantic version. However, prefixing a semantic version with a “v” is a common way (in English) to indicate it is a version number. Abbreviating “version” as “v” is often seen with version control. Example: git tag v1.2.3 -m “Release version 1.2.3”, in which case “v1.2.3” is a tag name and the semantic version is “1.2.3”.
The golang and go modules requires the leading v
and almost every project relies with the convention (for example kubernetes/kubernetes, docker/docker and etc.).
Masterminds/semver (the golang equivalent of this project) can optionally work with a v
prefix.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
That issue looks very similar to #210 which I’ve done lately. We’ve come to the conclusion that we do not want to support a function which doesn’t adhere to the semver specification. That means, we avoid partial parsing of a version string.
However, to support our developers, we think to add some recommendations to our documentation is a good idea. As such, I’ve written a short section into our documentation (see PR #215: “Dealing with Invalid Versions”).
@scls19fr With that background, I think, we can close this issue, right?
Why not just normalize version string (strip any
v
-like prefixes) before pass it to semver? This is quite simple operation and requires no changes for this project.