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

Function tree_label

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

Source from the content-addressed store, hash-verified

385}
386
387fn tree_label(node: &atomic_core::KgNode) -> String {
388 let label = if node.has_type(Class::File) {
389 metadata_text(node, "path").unwrap_or(&node.label)
390 } else {
391 &node.label
392 };
393 let label = one_line(label);
394 let status = metadata_text(node, "status")
395 .map(|value| format!(" [{}]", one_line(value)))
396 .unwrap_or_default();
397 if node.has_type(Class::Change) {
398 let id = node.id.rsplit(':').next().unwrap_or(&node.id);
399 let short: String = id.chars().take(12).collect();
400 if label.trim().is_empty() || label.trim() == short || label.trim() == id {
401 format!("{short}{status}")
402 } else {
403 let label = console::truncate_str(&label, 100, "…");
404 format!("{short} {label}{status}")
405 }
406 } else {
407 let label = console::truncate_str(&label, 100, "…");
408 format!("{label}{status}")
409 }
410}
411
412fn one_line(text: &str) -> String {
413 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