Move dry-run method to the top-level (#3567)

Trying to pull out some small, no-op refactors.
This commit is contained in:
Charlie Marsh 2024-05-13 22:28:39 -04:00 committed by GitHub
parent 025368965e
commit c666e43b90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1020,13 +1020,43 @@ async fn install(
} }
} }
#[allow(clippy::items_after_statements)] // TODO(konstin): Also check the cache whether any cached or installed dist is already known to
fn report_dry_run( // have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer.stderr(),
"{}{} {dist} is yanked.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer.stderr(),
"{}{} {dist} is yanked (reason: \"{reason}\").",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}
Ok(())
}
/// Report on the results of a dry-run installation.
fn report_dry_run(
resolution: &Resolution, resolution: &Resolution,
plan: Plan, plan: Plan,
start: std::time::Instant, start: std::time::Instant,
printer: Printer, printer: Printer,
) -> Result<(), Error> { ) -> Result<(), Error> {
let Plan { let Plan {
cached, cached,
remote, remote,
@ -1146,36 +1176,6 @@ async fn install(
} }
} }
Ok(())
}
// TODO(konstin): Also check the cache whether any cached or installed dist is already known to
// have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer.stderr(),
"{}{} {dist} is yanked.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer.stderr(),
"{}{} {dist} is yanked (reason: \"{reason}\").",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}
Ok(()) Ok(())
} }