-
Notifications
You must be signed in to change notification settings - Fork 883
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
feat: use semver
to match required version
#6066
base: master
Are you sure you want to change the base?
feat: use semver
to match required version
#6066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this one so soon. I'll be a little busy this coming weekend so I wanted to at least get my initial review done now. Good stuff so far!
…n' of github.com:ologbonowiwi/rustfmt into feat/rust-lang#6063/use-semver-to-check-required-version
changes addressed @ytmimi. Thanks for the quick feedback 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more notes, but we're moving in the right direction
Co-authored-by: Yacin Tmimi <[email protected]>
…n' of github.com:ologbonowiwi/rustfmt into feat/rust-lang#6063/use-semver-to-check-required-version
…lang#6063/use-semver-to-check-required-version
Co-authored-by: Yacin Tmimi <[email protected]>
…n' of github.com:ologbonowiwi/rustfmt into feat/rust-lang#6063/use-semver-to-check-required-version
ea85318
to
4e15dbf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor note about rewording the #### Multiple version to match
docs and maybe adding another test case for the wildcard match.
// These are not allowed. '*' can't be used with other version specifiers. | ||
#[test] | ||
fn test_wildcard_any_with_range() { | ||
assert!(!check_semver_version("*, <2.0.0", "1.0.0")); | ||
assert!(!check_semver_version("*, 1.0.0", "1.5.0")); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a check_semver_version
test that shows that *
matches any valid version when it's used on it's own? We do already have test_required_version_wildcard_any
above so maybe it's not necessary.
Except by `*`, any of the semver operators can be combined, being split with commas. The comparison is done using `&&` operator. | ||
|
||
`*` can't be used with other comparators. | ||
|
||
Since `*` has range restrictions, any comparator will override the wildcard operator. When `*` is used alone, the comparison always fails, as that's an invalid config. `*, <1.0.0` for example is invalid. | ||
|
||
Version requirements can't contradict themselves, otherwise they'll always fail. Some examples are `"1.*, >2.0.0"`, `1.0.*, >2.0.0` and `<1.5.0, >1.10.*`, because both requirements can't be true at the same time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could reword this slightly to hopefully make it clearer:
A comma separated list of version requirements.
The match succeeds when the current rustfmt version matches all version requirements.
The one notable exception is that a wildcard matching any version cannot be used in the list.
For example, `*, <1.0.0` will always fail.
Additionally, the version match will always fail if any of the version requirements contradict themselves.
Some examples of contradictory requirements are `1.*, >2.0.0`, `1.0.*, >2.0.0` and `<1.5.0, >1.10.*`.
required_version
semver
semver
to compare versionssemver
required_version
parsing manuallyCloses #6063