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,7 +1020,37 @@ async fn install(
} }
} }
#[allow(clippy::items_after_statements)] // 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(())
}
/// Report on the results of a dry-run installation.
fn report_dry_run( fn report_dry_run(
resolution: &Resolution, resolution: &Resolution,
plan: Plan, plan: Plan,
@ -1149,36 +1179,6 @@ async fn install(
Ok(()) 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(())
}
/// Validate the installed packages in the virtual environment. /// Validate the installed packages in the virtual environment.
fn validate( fn validate(
resolution: &Resolution, resolution: &Resolution,