Comments (15)
Yap, you're right but i don't think simply accepting such "wrong" versions would be an option. Maybe i could introduce a ParseTolerant
method which converts such versions to valid semvers. I will think about it.
Feel free to fork :)
from semver.
Great! Just submitted PR #19
from semver.
Hi, I had same problem. Thank you for fixing this issue.
However, the PR implementation seems wrong to me.
Version "1.0" generally means latest version of "1.0.x", not "1.0.0". So, why don't you parse "1.0" as "1.0.INT_MAX"?
from semver.
@awakia That's a fair point! I think the reason I didn't go that route was that serializing versions was a concern for my use case, and 1.0.9223372036854775807
looks a bit funky.
Since we almost certainly don't want to change the underlying data structure, one way to go would be changing the String()
function here to wrap the append
s of extra version parameters like so:
// Version to string
func (v Version) String() string {
b := make([]byte, 0, 5)
b = strconv.AppendUint(b, v.Major, 10)
if v.Minor != math.MaxUint64 {
b = append(b, '.')
b = strconv.AppendUint(b, v.Minor, 10)
}
if v.Patch != math.MaxUint64 {
b = append(b, '.')
b = strconv.AppendUint(b, v.Patch, 10)
}
// ...
This would maintain readability of the stringified versions. @blang what do you think?
from semver.
I think 1.0
is more like a range >0.9 <1.1
than a concrete version, but in case of a version i think 1.0
should be 1.0.0
. Using something like 1.0.MAX
would also imply: 1.0.0 < 1.0
and 1.0.0 != 1.0
which is counter intuitive imo.
Changing the String()
method would also break the spec kinda, that's a no-no.
But you might think about extending the range code, something like Return the last version included in the given range
from semver.
Yes, that's intended, because of the semver spec:
2. A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers[..]
"1.0" is not valid semver version, but "1.0.0" is.
from semver.
Oh did you edit your question or did i read wrong?
Since that is a semver library only, it would be spec breaking if i would allow "1.0" as a valid version.
from semver.
I added last sentence by editing the question (though before I saw your answer).
I will have to fork your lib, because all the world uses versions like "v1.0" and thinks that it is semver format. E.g. gopkg.in supports both v3, v3.N, or v3.N.M format.
from semver.
I don't see anything on gopkg.in that claims anything about semantic versioning (as described by semver.org.) I think the part you referenced, @vmihailenco, is about "selectors."
When using branches or tags to version the GitHub repository, gopkg.in understands that a selector in the URL such as "v1" may be satisfied by a tag or branch "v1.2" or "v1.2.1" (vMAJOR[.MINOR[.PATCH]]) in the repository, and will select the highest version satisfying the requested selector.
from semver.
from semver.
Thanks for the link. I am not going to argue about semver spec. I just think that v1 (or v1.0) is not any worse than v1.0.0 and I want to accept it as user input. And I don't see any complications for parser to support such format.
from semver.
I still think this repo should remain strict semver spec only, but i also think it would be a nice addition to support parsing other version variants (v1.0, 1.0, ..) in a separate library and build proper semvers out of it. Anyone interested in contributing?
from semver.
@blang Would you be open to adding the ParseTolerant
function you mentioned above if it was submitted in a PR?
from semver.
I guess that depends on the extend of this function. I think there is a lot of room for convenience beginning at a starting 'v' and ending up trimming spaces, removing quotes etc. If it's a small function with a limited scope and useful for most usecases i would be glad if someone could make this happen.
I think it should be fully decoupled and only preparing the version string before feeding it to Parse
.
from semver.
Thank you
from semver.
Related Issues (20)
- Support `^x.x.x`? HOT 2
- range issue perhaps? HOT 1
- support `~>`? HOT 2
- Help maintaining this library HOT 5
- Wrong module name HOT 2
- Support tildes, carets, hyphens, wildcards, etc
- ParseTolerant now fails on a valid semver HOT 2
- Bin Release
- proposal: remove pre-release versions >1.0.0 increment constraint HOT 5
- finalize version feature HOT 2
- Cannot install using go modules HOT 6
- How to compare the pre-release version? HOT 2
- 1.0.0-rc1 is greater then 1.0.0-rc11 HOT 2
- 0.2.10 is greater than v0.11.0 HOT 5
- Confusing behavior of Range with version with release tag HOT 1
- Fork with ^1.0.0 (caret), ~1.0.0 (tilda), 2 - 4 (subtraction range?) without any regex
- ParseTolerant "1.15-alpine3.14" returns error HOT 1
- Major version constraint circumvented by prerelease versions
- Using x in prerelease causes error
- Constraint check fails for .0 patch prereleases
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semver.