Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions crates/pixi_core/src/lock_file/satisfiability/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,25 @@ pub enum LocalMetadataMismatch {
},
}

/// Formats a list of requirements, showing only the first 3 names.
/// Render up to 3 distinct entries (`name` or `name[extras]`) and
/// `... and N more` for the rest.
fn format_requirements(reqs: &[pep508_rs::Requirement]) -> String {
const MAX_DISPLAY: usize = 3;
let names: Vec<_> = reqs
let mut seen = HashSet::new();
let unique: Vec<String> = reqs
.iter()
.take(MAX_DISPLAY)
.map(|r| r.name.to_string())
.map(|r| {
if r.extras.is_empty() {
r.name.to_string()
} else {
format!("{}[{}]", r.name, r.extras.iter().format(","))
}
})
.filter(|name| seen.insert(name.clone()))
.collect();
let formatted = names.join(", ");
if reqs.len() > MAX_DISPLAY {
format!("{}, ... and {} more", formatted, reqs.len() - MAX_DISPLAY)
let formatted = unique.iter().take(MAX_DISPLAY).format(", ").to_string();
if unique.len() > MAX_DISPLAY {
format!("{}, ... and {} more", formatted, unique.len() - MAX_DISPLAY)
} else {
formatted
}
Expand Down
Loading
Loading