refactor(resolve): Pull put locking message

This commit is contained in:
Ed Page 2024-04-12 20:41:51 -05:00
parent 17a11e493c
commit cb2bdea521
1 changed files with 10 additions and 7 deletions

View File

@ -212,9 +212,7 @@ fn print_lockfile_generation(
// just ourself, nothing worth reporting // just ourself, nothing worth reporting
return Ok(()); return Ok(());
} }
ws.gctx() status_locking(ws, num_pkgs)?;
.shell()
.status("Locking", format!("{num_pkgs} packages"))?;
for diff in diff { for diff in diff {
fn format_latest(version: semver::Version) -> String { fn format_latest(version: semver::Version) -> String {
@ -271,10 +269,7 @@ fn print_lockfile_sync(
if num_pkgs == 0 { if num_pkgs == 0 {
return Ok(()); return Ok(());
} }
let plural = if num_pkgs == 1 { "" } else { "s" }; status_locking(ws, num_pkgs)?;
ws.gctx()
.shell()
.status("Locking", format!("{num_pkgs} package{plural}"))?;
for diff in diff { for diff in diff {
fn format_latest(version: semver::Version) -> String { fn format_latest(version: semver::Version) -> String {
@ -488,6 +483,14 @@ fn print_lockfile_updates(
Ok(()) Ok(())
} }
fn status_locking(ws: &Workspace<'_>, num_pkgs: usize) -> CargoResult<()> {
let plural = if num_pkgs == 1 { "" } else { "s" };
ws.gctx()
.shell()
.status("Locking", format!("{num_pkgs} package{plural}"))?;
Ok(())
}
fn is_latest(candidate: &semver::Version, current: &semver::Version) -> bool { fn is_latest(candidate: &semver::Version, current: &semver::Version) -> bool {
current < candidate current < candidate
// Only match pre-release if major.minor.patch are the same // Only match pre-release if major.minor.patch are the same