Skip to content

Commit dbca11f

Browse files
committed
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
1 parent 064c70b commit dbca11f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,20 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
244244
&anstyle::Style::new().bold(),
245245
)?;
246246
}
247-
} else {
248-
if !unchanged.is_empty() {
249-
unchanged_behind += 1;
250-
}
251247
}
248+
unchanged_behind += unchanged.len();
252249
}
253250
}
254-
if 0 < unchanged_behind {
255-
opts.config.shell().note(format!(
256-
"Pass `--verbose` to see {unchanged_behind} unchanged dependencies behind latest"
257-
))?;
251+
if opts.config.shell().verbosity() == Verbosity::Verbose {
252+
opts.config.shell().note(
253+
"To see how you depend on a package, run `cargo tree --invert --package <dep>@<ver>`",
254+
)?;
255+
} else {
256+
if 0 < unchanged_behind {
257+
opts.config.shell().note(format!(
258+
"Pass `--verbose` to see {unchanged_behind} unchanged dependencies behind latest"
259+
))?;
260+
}
258261
}
259262
if opts.dry_run {
260263
opts.config

tests/testsuite/update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,7 @@ fn report_behind() {
15201520
[UPDATING] `dummy-registry` index
15211521
[UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0)
15221522
[UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1)
1523+
[NOTE] To see how you depend on a package, run `cargo tree --invert --package <dep>@<ver>`
15231524
[WARNING] not updating lockfile due to dry run
15241525
",
15251526
)
@@ -1543,6 +1544,7 @@ fn report_behind() {
15431544
[UPDATING] `dummy-registry` index
15441545
[UNCHANGED] breaking v0.1.1 (latest: v0.2.0)
15451546
[UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1)
1547+
[NOTE] To see how you depend on a package, run `cargo tree --invert --package <dep>@<ver>`
15461548
[WARNING] not updating lockfile due to dry run
15471549
",
15481550
)

0 commit comments

Comments
 (0)