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

Function format_local_state

atomic-cli/src/commands/pull/helpers.rs:336–357  ·  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

334///
335/// A formatted string like "at ABC123... (10 changes)" or "(empty)".
336fn format_local_state(entries: &[HistoryEntry]) -> String {
337 if entries.is_empty() {
338 return hint("(empty)").to_string();
339 }
340
341 if let Some(last) = entries.last() {
342 let hash_str = last.hash.to_base32();
343 let hash_short = &hash_str[..12.min(hash_str.len())];
344 format!(
345 "at {}... ({} {})",
346 hint(hash_short),
347 entries.len(),
348 if entries.len() == 1 {
349 "change"
350 } else {
351 "changes"
352 }
353 )
354 } else {
355 hint("(empty)").to_string()
356 }
357}
358
359/// Format the remote state for display.
360///

Calls 5

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