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])
| 367 | /// |
| 368 | /// A formatted string like "at DEF456... (15 changes)" or "(empty)". |
| 369 | fn 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 |