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

Support for constraint operators caret (^) and tilde (~) #14

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

constraint.go Outdated Show resolved Hide resolved
@6543
Copy link
Owner Author

6543 commented Nov 19, 2020

^ is nice option but I'm not sure if we should go the same way with ~ as it could also be understand as "kind of":

  • ~1.2.3 is equivalent to >= 1.2.3, < 1.2.4
  • ~1.1.1.1 is equivalent to >= 1.1.1.1.0, < 1.1.1.2
    so make it recursive if constrain contain more digits

@6543
Copy link
Owner Author

6543 commented Nov 19, 2020

@beornf do you have an option on this? ☝️

@beornf
Copy link

beornf commented Nov 19, 2020

Yeah it would make sense to loop through all the segments in the same way as the pessimistic operator

go-version/constraint.go

Lines 186 to 193 in bcb907f

// Check the segments in the constraint against those in the version. If the version
// being checked, at any point, does not have the same values in each index of the
// constraints segments, then it cannot be valid against the constraint.
for i := 0; i < c.si-1; i++ {
if v.segments[i] != c.segments[i] {
return false
}
}

Note the pessimistic operator is subtly different to tilde operator following:

  • ~>1.2.3 is equivalent to >=1.2.3, <1.3.0
  • ~>1.1.1.1 is equivalent to >=1.1.1.1, <1.1.2.0

@6543 6543 added the wip label Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants