Skip to content

Commit

Permalink
fix(update): Help people discover how they pull in a stale dep
Browse files Browse the repository at this point in the history
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
  • Loading branch information
epage committed Jan 31, 2024
1 parent 064c70b commit dbca11f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/cargo/ops/cargo_generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dep>@<ver>`",
)?;
} 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
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dep>@<ver>`
[WARNING] not updating lockfile due to dry run
",
)
Expand All @@ -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 <dep>@<ver>`
[WARNING] not updating lockfile due to dry run
",
)
Expand Down

0 comments on commit dbca11f

Please sign in to comment.