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

Function format_remote_state

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

385///
386/// A formatted string like "at DEF456... (15 changes)" or "(empty)".
387fn format_remote_state(state: &StateResponse, entries: &[ChangelistEntry]) -> String {
388 if state.is_empty() || entries.is_empty() {
389 return hint("(empty)").to_string();
390 }
391
392 if let Some(merkle) = state.merkle() {
393 let merkle_short = &merkle[..12.min(merkle.len())];
394 format!(
395 "at {}... ({} {})",
396 hint(merkle_short),
397 entries.len(),
398 if entries.len() == 1 {
399 "change"
400 } else {
401 "changes"
402 }
403 )
404 } else {
405 hint("(empty)").to_string()
406 }
407}
408
409// Formatting Utilities
410

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