MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / tree_label

Function tree_label

atomic-cli/src/commands/intent/graph.rs:368–391  ·  view source on GitHub ↗
(node: &atomic_core::KgNode)

Source from the content-addressed store, hash-verified

366}
367
368fn tree_label(node: &atomic_core::KgNode) -> String {
369 let label = if node.has_type(Class::File) {
370 metadata_text(node, "path").unwrap_or(&node.label)
371 } else {
372 &node.label
373 };
374 let label = one_line(label);
375 let status = metadata_text(node, "status")
376 .map(|value| format!(" [{}]", one_line(value)))
377 .unwrap_or_default();
378 if node.has_type(Class::Change) {
379 let id = node.id.rsplit(':').next().unwrap_or(&node.id);
380 let short: String = id.chars().take(12).collect();
381 if label.trim().is_empty() || label.trim() == short || label.trim() == id {
382 format!("{short}{status}")
383 } else {
384 let label = console::truncate_str(&label, 100, "…");
385 format!("{short} {label}{status}")
386 }
387 } else {
388 let label = console::truncate_str(&label, 100, "…");
389 format!("{label}{status}")
390 }
391}
392
393fn one_line(text: &str) -> String {
394 text.chars()

Callers 1

render_treeFunction · 0.85

Calls 6

metadata_textFunction · 0.85
has_typeMethod · 0.80
one_lineFunction · 0.70
nextMethod · 0.45
collectMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected