New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3 - Constraints don't appear to work as expected #150
Comments
What's really strange is the final constraint check - |
Isn't this topic related to #21 |
@antonosmond I think I can answer this. I modified your playground a little to show this. See https://play.golang.org/p/w4UElRmiFQz. I hope this helps. |
@mattfarina From the output of https://play.golang.org/p/w4UElRmiFQz:
So 1.0.0-rc1 is not less than 1.0-0, but is less than or equal to 1.0-0, so ... it must be equal? |
@squaremo I can answer this. |
This seems like a pretty severe bug. |
@mattolenik expanding to https://play.golang.org/p/t8fAR9oVDV8
it's not compatible with ranges that don't specify they explicitly work with prereleases. Based on @mattfarina's explanation above, 1.x-0 translates to 1.x.x-x, all wildcards, and it's equal. See also #21 and https://semver.org/#spec-item-9 honestly i think this could be closed, working as intended in #23 |
It's important to note that semver has a specific format for versions. The range syntax that is in use has no specification. In fact, different systems do ranges differently. Helm is currently patterned after what JS and Rust do. The JS libs (used in npm itself) may be the most widely used range usage. |
I must be missing something...how does any of that have bearing on a version starting with major version 1 being less than a version starting with 2? Should I open a second issue for that? Surely my example cannot be expected behavior! |
To document, here's some details on what's going on with the examples...
When wildcards are expanded to ranges it helps to explain why the results are what they are. |
I know that this is old, but it's still open. Also, some of the Go Playgrounds differed from what was actually being asked, and according to the spec, @mattolenik and @antonosmond are correct that this is a bug. Let's get rid of the https://go.dev/play/p/NbjUjgQHpwL This Go Playground says that:
…which any human knows is incorrect. Reviewing https://semver.org/#spec-item-11, §11.1,2 says:
We definitely see this in the example above with numeric-only versions. The following comparisons match both the spec and also human intelligence.
When we get to §11.3, however, we begin to see issues.
If we just look at the example provided, this package fails the test.
If we take the other obviously-prerelease versions, we see the following — all of which are incorrect behavior per §11.1-3.
Important I want to be absolutely clear that this is not comparing against I understand that while versions like
However, I want to explicitly call out this part — which implies that this rule also applies to versions with different major, minor, and patch values (although does not directly state it). There is a better explanation in §2, where it says:
Rules are applied in-order:
So, when we use this package to compare certain versions, we can see that the package violates the rules of both §2 and also §11.4.
What the spec says, and also what humans expect, is the following:
Looking at a second example, https://go.dev/play/p/XOHvsLysvWE, I threw in a comparison to a prerelease. And when you do this, the comparison is suddenly correct.
There appears to be a bug when comparing prerelease vs non-prerelease versions where (at the very least), comparing major versions stops producing correct results. Of final note is that sorting appears to work correctly. https://go.dev/play/p/hLAs7QTgVln. This bug seems to only affect comparators. |
The semver spec states that prerelease versions always have a lower precedence than a normal version (https://semver.org/#spec-item-11).
Given:
1.0.0-rc1
should be <1.0.0
.Given a constraint e.g.
< 1.0.0-0
I'd expect1.0.0-rc1
to be flagged as true in the constraint check because it IS less than1.0.0
however this doesn't appear to be working.Have a look at this: https://play.golang.org/p/boXFhusKDBw
In every case, the prerelease version "should" have a value of
true
but it doesn't.Is this a bug or am I misunderstanding something?
The text was updated successfully, but these errors were encountered: