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

Implement semver ranges for install --vers #4229

Merged
merged 2 commits into from
Jun 28, 2017

Conversation

azerupi
Copy link
Contributor

@azerupi azerupi commented Jun 26, 2017

This implements the design discussed in #4207
It allows to specify semver ranges on cargo install ... --vers

  1. The first character of the --vers value is checked, if there is none we return an error.
  2. If it is one of <, >, =, ^, ~ we parse the value as a VersionReq, otherwise we parse it as a Version.
  3. If the parsing as a Version fails but parsing as VersionReq succeeds, we add a note to the warning mentioning that a qualifier should be used to specify a semver range. This catches versions with less than tree digits.

Otherwise, the previous behaviour is preserved with the warning of backwards compatibility.

This means that

  • cargo install ... --vers "^1.2.3" will be parsed as a range
  • cargo install ... --vers 1.2.3 will be parsed as a version
  • cargo install ... --vers 1.2 will be parsed as a version for backwards compatibility reasons, fail and be passed through as is,but we will add a note if you want to specify semver range, add an explicit qualifier, like ^1.2
  • cargo install ... --vers blah will be parsed as a version for backwards compatibility reasons (which is weird because it is not even a valid semver range) and produce an unknown error down the line. I have left this behaviour untouched because it worked like that before, but I can easily make it error sooner with a better message.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matklad (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton alexcrichton added the relnotes Release-note worthy label Jun 26, 2017
}


Copy link
Member

Choose a reason for hiding this comment

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

Looks like a couple of accidentally added blank lines :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes! I will correct that right away :)

@matklad
Copy link
Member

matklad commented Jun 26, 2017

Looks great, @azerupi ! Hope we don't forget to remove the fallback after a couple of releases :)

@matklad
Copy link
Member

matklad commented Jun 27, 2017

Looks great, and there are already cargo install tests that check this behavior.

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2017

📌 Commit d9afb2d has been approved by matklad

@bors
Copy link
Contributor

bors commented Jun 27, 2017

⌛ Testing commit d9afb2d with merge cef6833...

bors added a commit that referenced this pull request Jun 27, 2017
Implement semver ranges for install --vers

This implements the design discussed in #4207
It allows to specify semver ranges on `cargo install ... --vers`

1. The first character of the `--vers` value is checked, if there is none we return an error.
2. If it is one of `<`, `>`, `=`, `^`, `~` we parse the value as a `VersionReq`, otherwise we parse it as a `Version`.
3. If the parsing as a `Version` fails but parsing as `VersionReq` succeeds, we add a note to the warning mentioning that a qualifier should be used to specify a semver range. This catches versions with less than tree digits.

Otherwise, the previous behaviour is preserved with the warning of backwards compatibility.

This means that

- `cargo install ... --vers "^1.2.3"` will be parsed as a range
- `cargo install ... --vers 1.2.3` will be parsed as a version
- `cargo install ... --vers 1.2` will be parsed as a version for backwards compatibility reasons, fail and be passed through as is,**but** we will add a note `if you want to specify semver range, add an explicit qualifier, like ^1.2`
- `cargo install ... --vers blah` will be parsed as a version for backwards compatibility reasons (which is weird because it is not even a valid semver range) and produce an `unknown error` down the line. I have left this behaviour untouched because it worked like that before, but I can easily make it error sooner with a better message.
@bors
Copy link
Contributor

bors commented Jun 28, 2017

💥 Test timed out

@matklad
Copy link
Member

matklad commented Jun 28, 2017

@bors retry

@bors
Copy link
Contributor

bors commented Jun 28, 2017

⌛ Testing commit d9afb2d with merge 64c3217...

bors added a commit that referenced this pull request Jun 28, 2017
Implement semver ranges for install --vers

This implements the design discussed in #4207
It allows to specify semver ranges on `cargo install ... --vers`

1. The first character of the `--vers` value is checked, if there is none we return an error.
2. If it is one of `<`, `>`, `=`, `^`, `~` we parse the value as a `VersionReq`, otherwise we parse it as a `Version`.
3. If the parsing as a `Version` fails but parsing as `VersionReq` succeeds, we add a note to the warning mentioning that a qualifier should be used to specify a semver range. This catches versions with less than tree digits.

Otherwise, the previous behaviour is preserved with the warning of backwards compatibility.

This means that

- `cargo install ... --vers "^1.2.3"` will be parsed as a range
- `cargo install ... --vers 1.2.3` will be parsed as a version
- `cargo install ... --vers 1.2` will be parsed as a version for backwards compatibility reasons, fail and be passed through as is,**but** we will add a note `if you want to specify semver range, add an explicit qualifier, like ^1.2`
- `cargo install ... --vers blah` will be parsed as a version for backwards compatibility reasons (which is weird because it is not even a valid semver range) and produce an `unknown error` down the line. I have left this behaviour untouched because it worked like that before, but I can easily make it error sooner with a better message.
@bors
Copy link
Contributor

bors commented Jun 28, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: matklad
Pushing 64c3217 to master...

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

Successfully merging this pull request may close these issues.

6 participants