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

Print information about updated packages on cargo update. #1621

Closed
wants to merge 3 commits into from
Closed

Print information about updated packages on cargo update. #1621

wants to merge 3 commits into from

Conversation

pyfisch
Copy link

@pyfisch pyfisch commented May 17, 2015

Solves #984

@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 @wycats (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. 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 CONTRIBUTING.md for more information.

match dependencies.get(dep.name()) {
Some(&version) => {
if version != dep.version() {
println!(" Updating {} v{} -> v{}", dep.name(), dep.version(), version)
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 thread through the Shell from UpdateOptions instead of printing directly to stdout?

@alexcrichton
Copy link
Member

Nice, thanks! Could you also add some tests for the other messages printed like "Removed" and "New dependency"?

@pyfisch
Copy link
Author

pyfisch commented May 18, 2015

I will use the Shell and add tests. I have to refactor my code since it returns different results on different runs due to the unordered nature of HashMap 😄

@pyfisch
Copy link
Author

pyfisch commented May 19, 2015

Adressed all comments by @alexcrichton

} else {Ok(())}
}
(None, None) => unreachable!(),
});
Copy link
Member

Choose a reason for hiding this comment

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

This may be better structured like:

let (status, msg) = match dep {
    (None, Some(pkg)) => ("Adding", format!(...)),
    (Some(pkg), None) => ("Removing", format!(...)),
    (Some(pkg1), Some(pkg2)) => {
        if pkg1.version() == pkg2.version() { continue }
        ("Updating", format!(...))
    }
    (None, None) => continue,
};
try!(opts.config.shell().status(...))

@alexcrichton
Copy link
Member

Looking great! I added some comments about different sources and multiple versions, and it would be nice to have exhaustive tests but it's ok to skimp a little bit. It would, however, be nice to see at least a test for multiple versions in an existing graph being updated to one version in a later graph (just to see what the output does).

@alexcrichton
Copy link
Member

In talking with @wycats, he also brings up that the dependency graph can change as a result of a modification of Cargo.toml followed by cargo build. In this case we probably want at least the ability to print the updates, but probably only with the --verbose flag. Could you make sure that code path is covered as well?

@wycats
Copy link
Contributor

wycats commented May 21, 2015

It would, however, be nice to see at least a test for multiple versions in an existing graph being updated to one version in a later graph (just to see what the output does)

I also would like to see an actual output screenshot for these kinds of significant changes 😄

@alexcrichton
Copy link
Member

It seems that this has stalled since opening, so I'm going to close, but feel free to reopen with comments addressed!

bors added a commit that referenced this pull request Aug 28, 2015
Compare #1621.  Like that pull request, this one solves #984.

I have rewritten most of @pyfisch's logic to account for @alexcrichton's comments.  Specifically, this code will correctly handle adding/removing multiple versions of one package, as well as several packages with different sources, but the same name.

The output looks like this:

```
[georgev@desertvoice cargo]$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating libc v0.1.8 -> v0.1.10
    Updating memchr v0.1.3 -> v0.1.5
    Updating num v0.1.26 -> v0.1.27
    Updating rand v0.3.9 -> v0.3.10
    Updating rustc-serialize v0.3.15 -> v0.3.16
```

Comments welcome.

r? @alexcrichton
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.

4 participants