| 289 | } |
| 290 | |
| 291 | fn path_nodes(paths: PathTree, show_hunks: bool) -> Vec<Tree> { |
| 292 | paths |
| 293 | .children |
| 294 | .into_iter() |
| 295 | .map(|(name, path)| { |
| 296 | let slash = if path.directory || !path.children.is_empty() { |
| 297 | "/" |
| 298 | } else { |
| 299 | "" |
| 300 | }; |
| 301 | let badge = path |
| 302 | .summary |
| 303 | .as_ref() |
| 304 | .map(|summary| format!(" [{}]", status(summary.symbol))) |
| 305 | .unwrap_or_default(); |
| 306 | let mut node = Tree::new(format!("{name}{slash}{badge}")); |
| 307 | if show_hunks { |
| 308 | if let Some(summary) = &path.summary { |
| 309 | node.push(summary.info.trim_start_matches('(').trim_end_matches(')')); |
| 310 | } |
| 311 | } |
| 312 | node.children.extend(path_nodes(path, show_hunks)); |
| 313 | node |
| 314 | }) |
| 315 | .collect() |
| 316 | } |
| 317 | |
| 318 | fn status(symbol: &str) -> &str { |
| 319 | match symbol { |