Skip to content
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

strict version checking feature #243

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Diliz
Copy link

@Diliz Diliz commented Jun 14, 2024

As described here: #242

Implemented strict version checking, which is not a breaking change.
So it should have no impact on the previous features 👍

constraints.go Show resolved Hide resolved
constraints_test.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
* `==1.2.1-alpha` will only look for a `1.2.1-alpha` preleased version
* `==1.2.1+alpha` will only look for a `1.2.1-alpha` preleased version

> This helps looking for a very specific version only, the `=` operator (or the no operator) will be ok with metadatas in the version in the first place, ex: `=1.2.1` will be equivalent to `=1.2.1+x` where `x` can be any medatata.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described here, the issue lied in here, we are not able to differentiate a version with metadatas and a version without metadatas with the actual constraints comparisons possibilities

{"4.1.x", "4.1.3", true},
{"4.1.x", "4.1.3+alpha", true},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the issue, it's also the case without dirty

@Diliz
Copy link
Author

Diliz commented Jul 1, 2024

any news regarding this pull request? @mattfarina

@Diliz
Copy link
Author

Diliz commented Aug 22, 2024

Any news on that @mattfarina ?
It would fix an issue with helm which is relying on this library: helm/helm#13056

Comment on lines +143 to +151
{"==2", "1", false},
{"==2", "3.4.5", false},
{"==2", "2.0.0", false},
{"==2", "2.0.0+alpha", false},
{"==2", "2.0.0-alpha", false},
{"==2", "2.0.1", false},
{"==2.1", "2.1.0", false},
{"==2.1.x", "2.1.0", false},
{"==2.1.x", "2.1.1", false},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't have a version that's "2". So, a constraint of ==2 can never be matched against.

Since other comparisons allow shortened versions with assumptions on missing parts this looks to be confusing to user input that's run through here. That, I think, means more support requests.

node-semver does == and === which you can find out about at https://github.com/npm/node-semver?tab=readme-ov-file#comparison.

When I look at === with missing parts (e.g., ===1) it falls into a loose rather than exact string situation. but, if you put a full semver in there is a string comparison.

What do you think of the node-semver model?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your point, since there was no double equal operator I didn't thinked too much about it, maybe I am wrong, here what I think should be some constraints examples that follows the node-semver model:

  • simple equal operator = :
"=2.x.x", "2.0.1", true
"=2.x.x", "2.0.1+mybuild", true
"=2.x.x", "2.0.1-beta+mybuild", true
"=2.x.x+build", "2.0.1", false
"=2.x.x+build", "2.0.1+mybuild", true
"=2.x.x-beta+build", "2.0.1+mybuild", (true or false)? # In this case, in the node model, the version and the build would correspond, so it could be equal if beta is not taken into account
"=2.x.x-beta+build", "2.0.1-beta+mybuild", true
  • double equal operator == :
"==2.x.x", "2.0.1", true
"==2.x.x", "2.0.1+mybuild", false
"==2.x.x", "2.0.1-beta+mybuild", false
"==2.x.x+build", "2.0.1", false
"==2.x.x+build", "2.0.1+mybuild", true
"==2.x.x-beta+build", "2.0.1+mybuild", false
"==2.x.x-beta+build", "2.0.1-beta+mybuild", true
  • triple equal operator === :
"===2.x.x", "2.0.1", false
"===2.x.x", "2.0.1+mybuild", false
"===2.x.x", "2.0.1-beta+mybuild", false
"===2.x.x+build", "2.0.1", false
"===2.x.x+build", "2.0.1+mybuild", false
"===2.x.x-beta+build", "2.0.1+mybuild", false
"===2.x.x-beta+build", "2.0.1-beta+mybuild", false
"===2.0.1", "2.0.1", true
"===2.0.1", "2.0.1+mybuild", false
"===2.0.1", "2.0.1-beta+mybuild", false
"===2.0.1+build", "2.0.1", false
"===2.0.1+build", "2.0.1+mybuild", true
"===2.0.1-beta+build", "2.0.1+mybuild", false
"===2.0.1-beta+build", "2.0.1-beta+mybuild", true

I'm pretty much ok with the node-semver model, and this example as well, if we can be sure to find a specific version or subset of versions it would be perfect 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants