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