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

Function format_remote_state

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

Format the remote state for display. # Arguments `state` - The remote's state response `entries` - The remote's changelist entries # Returns A formatted string like "at DEF456... (15 changes)" or "(empty)".

(state: &StateResponse, entries: &[ChangelistEntry])

Source from the content-addressed store, hash-verified

367///
368/// A formatted string like "at DEF456... (15 changes)" or "(empty)".
369fn format_remote_state(state: &StateResponse, entries: &[ChangelistEntry]) -> String {
370 if state.is_empty() || entries.is_empty() {
371 return hint("(empty)").to_string();
372 }
373
374 if let Some(merkle) = state.merkle() {
375 let merkle_short = &merkle[..12.min(merkle.len())];
376 format!(
377 "at {}... ({} {})",
378 hint(merkle_short),
379 entries.len(),
380 if entries.len() == 1 {
381 "change"
382 } else {
383 "changes"
384 }
385 )
386 } else {
387 hint("(empty)").to_string()
388 }
389}
390
391// Formatting Utilities
392

Callers 2

display_state_comparisonFunction · 0.70

Calls 4

hintFunction · 0.85
merkleMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by 1