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

Function format_local_state

atomic-cli/src/commands/pull/helpers.rs:354–375  ·  view source on GitHub ↗

Format the local state for display. # Arguments `entries` - Local history entries # Returns A formatted string like "at ABC123... (10 changes)" or "(empty)".

(entries: &[HistoryEntry])

Source from the content-addressed store, hash-verified

352///
353/// A formatted string like "at ABC123... (10 changes)" or "(empty)".
354fn format_local_state(entries: &[HistoryEntry]) -> String {
355 if entries.is_empty() {
356 return hint("(empty)").to_string();
357 }
358
359 if let Some(last) = entries.last() {
360 let hash_str = last.hash.to_base32();
361 let hash_short = &hash_str[..12.min(hash_str.len())];
362 format!(
363 "at {}... ({} {})",
364 hint(hash_short),
365 entries.len(),
366 if entries.len() == 1 {
367 "change"
368 } else {
369 "changes"
370 }
371 )
372 } else {
373 hint("(empty)").to_string()
374 }
375}
376
377/// Format the remote state for display.
378///

Calls 5

hintFunction · 0.85
lastMethod · 0.80
is_emptyMethod · 0.45
to_base32Method · 0.45
lenMethod · 0.45