-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix #2773 with new precise encode #5205
Conversation
src/cargo/sources/registry/index.rs
Outdated
let vers = &p[dep.name().len() + 1..]; | ||
s.version().to_string() == vers | ||
let vers: Vec<&str> = p[dep.name().len() + 1..].split("->").collect(); | ||
if dep.version_req().matches(&Version::parse(vers[0]).unwrap()) { |
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.
The indentation look off and might be nicer to have an else
maybe?
src/cargo/sources/registry/index.rs
Outdated
|
||
if dep.version_req().matches(&Version::parse(vers[0]).unwrap()) { | ||
return vers[1] == s.version().to_string() | ||
} { |
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.
else
src/cargo/sources/registry/index.rs
Outdated
s.version().to_string() == vers | ||
let vers: Vec<&str> = p[dep.name().len() + 1..].split("->").collect(); | ||
if dep.version_req().matches(&Version::parse(vers[0]).unwrap()) { | ||
return vers[1] == s.version().to_string() |
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.
drop the return
so rustfmt will be happy and squash the set in a single patch please.
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.
Looks great to me, thanks! Mind also adding a test for this?
src/cargo/sources/registry/index.rs
Outdated
// version requested (argument to `--precise`). | ||
let summaries = summaries.filter(|s| match source_id.precise() { | ||
Some(p) if p.starts_with(&*dep.name()) && p[dep.name().len()..].starts_with('=') => { | ||
let vers = &p[dep.name().len() + 1..]; | ||
s.version().to_string() == vers | ||
let vers: Vec<&str> = p[dep.name().len() + 1..].split("->").collect(); |
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.
Could this use splitn
with 2, and avoid the intermediate Vec
allocation by using next().unwrap()
as well?
Nice! I think there may be a merge conflict now though? |
ping @alexcrichton |
@bors: r+ |
📌 Commit 1a26e86 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Read/write the encoded `cargo update --precise` in the same place ### What does this PR try to resolve? There's a stringly typed interface between https://github.com/rust-lang/cargo/blob/de7537e63296ee13cb78611a988bcc9a6ac26134/src/cargo/ops/cargo_generate_lockfile.rs#L105 and https://github.com/rust-lang/cargo/blob/de7537e63296ee13cb78611a988bcc9a6ac26134/src/cargo/sources/registry/index.rs#L587, the only reason I found it with by finding the original commit #5205 As far as I can tell, anyone could just create this internally meaningful ~structure~ string by passing it on the command line. This should get cleaned up, for now by moving the encoding and decoding in to the same file. ### How should we test and review this PR? Internal refactor and test still pass. ### Additional information I am hoping that in the redesign of `cargo update` we can come up with a better design for smuggling this data from the API all the way to querying the registry. It seems like locking the dependency to the selected version would be conceptually simpler, or using the patch system, or something.
Changed the precise encode from = to =<present_version>-><future_version> in order to check the correct requirements.
cc @lu-zero