Skip to content

Commit

Permalink
refactor(update): Clarify what each checks intention is
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 13, 2024
1 parent 9d5c149 commit 2107a43
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/cargo/ops/cargo_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
let version_req = package_id.version().to_caret_req();
let required_rust_version = change.required_rust_version.as_ref();

if let Some(summary) = possibilities
let compat_ver_compat_msrv_summary = possibilities
.iter()
.map(|s| s.as_summary())
.filter(|s| {
Expand All @@ -787,15 +787,15 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
}
})
.filter(|s| package_id.version() != s.version() && version_req.matches(s.version()))
.max_by_key(|s| s.version())
{
.max_by_key(|s| s.version());
if let Some(summary) = compat_ver_compat_msrv_summary {
let warn = style::WARN;
let version = summary.version();
let report = format!(" {warn}(available: v{version}){warn:#}");
return Some(report);
}

if let Some(summary) = possibilities
let incompat_ver_compat_msrv_summary = possibilities
.iter()
.map(|s| s.as_summary())
.filter(|s| {
Expand All @@ -808,8 +808,8 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
}
})
.filter(|s| is_latest(s.version(), package_id.version()))
.max_by_key(|s| s.version())
{
.max_by_key(|s| s.version());
if let Some(summary) = incompat_ver_compat_msrv_summary {
let warn = if change.is_transitive.unwrap_or(true) {
Default::default()
} else {
Expand All @@ -820,12 +820,12 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
return Some(report);
}

if let Some(summary) = possibilities
let compat_ver_summary = possibilities
.iter()
.map(|s| s.as_summary())
.filter(|s| package_id.version() != s.version() && version_req.matches(s.version()))
.max_by_key(|s| s.version())
{
.max_by_key(|s| s.version());
if let Some(summary) = compat_ver_summary {
let msrv_note = summary
.rust_version()
.map(|rv| format!(", requires Rust {rv}"))
Expand All @@ -836,12 +836,12 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
return Some(report);
}

if let Some(summary) = possibilities
let incompat_ver_summary = possibilities
.iter()
.map(|s| s.as_summary())
.filter(|s| is_latest(s.version(), package_id.version()))
.max_by_key(|s| s.version())
{
.max_by_key(|s| s.version());
if let Some(summary) = incompat_ver_summary {
let msrv_note = summary
.rust_version()
.map(|rv| format!(", requires Rust {rv}"))
Expand Down

0 comments on commit 2107a43

Please sign in to comment.