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

fix #2773 with new precise encode #5205

Merged
merged 5 commits into from
Mar 27, 2018
Merged

fix #2773 with new precise encode #5205

merged 5 commits into from
Mar 27, 2018

Conversation

gibix
Copy link
Contributor

@gibix gibix commented Mar 19, 2018

Changed the precise encode from = to =<present_version>-><future_version> in order to check the correct requirements.

cc @lu-zero

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()) {
Copy link
Contributor

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?


if dep.version_req().matches(&Version::parse(vers[0]).unwrap()) {
return vers[1] == s.version().to_string()
} {
Copy link
Contributor

Choose a reason for hiding this comment

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

else

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()
Copy link
Contributor

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.

Copy link
Member

@alexcrichton alexcrichton left a 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?

// 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();
Copy link
Member

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?

@alexcrichton
Copy link
Member

Nice! I think there may be a merge conflict now though?

@matklad
Copy link
Member

matklad commented Mar 27, 2018

ping @alexcrichton

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 27, 2018

📌 Commit 1a26e86 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Mar 27, 2018

⌛ Testing commit 1a26e86 with merge d079a10...

bors added a commit that referenced this pull request Mar 27, 2018
fix #2773 with new precise encode

Changed the precise encode from <pkg>=<precise> to <pkg>=<present_version>-><future_version> in order to check the correct requirements.

cc @lu-zero
@bors
Copy link
Contributor

bors commented Mar 27, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing d079a10 to master...

@bors bors merged commit 1a26e86 into rust-lang:master Mar 27, 2018
@ehuss ehuss added this to the 1.26.0 milestone Feb 6, 2022
bors added a commit that referenced this pull request Sep 6, 2023
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.
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.

6 participants