From dbca11ff2b46fd2909c9607a4fa334175a7a1567 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 30 Jan 2024 19:20:23 -0600 Subject: [PATCH] fix(update): Help people discover how they pull in a stale dep I put this behind `--verbose` - To keep the output down in the standard case - Because its assuming most people's "behind" dependencies will be "Unchanged" and so that is when knowing how to look up how its pulled in is useful --- src/cargo/ops/cargo_generate_lockfile.rs | 19 +++++++++++-------- tests/testsuite/update.rs | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index f401001bd420..e13894bba3dd 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -244,17 +244,20 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes &anstyle::Style::new().bold(), )?; } - } else { - if !unchanged.is_empty() { - unchanged_behind += 1; - } } + unchanged_behind += unchanged.len(); } } - if 0 < unchanged_behind { - opts.config.shell().note(format!( - "Pass `--verbose` to see {unchanged_behind} unchanged dependencies behind latest" - ))?; + if opts.config.shell().verbosity() == Verbosity::Verbose { + opts.config.shell().note( + "To see how you depend on a package, run `cargo tree --invert --package @`", + )?; + } else { + if 0 < unchanged_behind { + opts.config.shell().note(format!( + "Pass `--verbose` to see {unchanged_behind} unchanged dependencies behind latest" + ))?; + } } if opts.dry_run { opts.config diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 5dd8d726e91b..73baa7a34196 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -1520,6 +1520,7 @@ fn report_behind() { [UPDATING] `dummy-registry` index [UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0) [UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1) +[NOTE] To see how you depend on a package, run `cargo tree --invert --package @` [WARNING] not updating lockfile due to dry run ", ) @@ -1543,6 +1544,7 @@ fn report_behind() { [UPDATING] `dummy-registry` index [UNCHANGED] breaking v0.1.1 (latest: v0.2.0) [UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1) +[NOTE] To see how you depend on a package, run `cargo tree --invert --package @` [WARNING] not updating lockfile due to dry run ", )