Print the status in long (human-readable) format.
(&self, status: &RepositoryStatus)
| 256 | |
| 257 | /// Print the status in long (human-readable) format. |
| 258 | fn print_long_format(&self, status: &RepositoryStatus) -> CliResult<()> { |
| 259 | // Print view info |
| 260 | print!("On view "); |
| 261 | println!("{}", style_view(status.view())); |
| 262 | |
| 263 | // Print state hash if available |
| 264 | if let Some(state) = status.state() { |
| 265 | let state_str = state.to_base32(); |
| 266 | // Truncate to default hash length for display |
| 267 | let short_state = if state_str.len() > DEFAULT_HASH_LENGTH { |
| 268 | format!("{}...", &state_str[..DEFAULT_HASH_LENGTH]) |
| 269 | } else { |
| 270 | state_str |
| 271 | }; |
| 272 | print!("State: "); |
| 273 | println!("{}", hash(&short_state)); |
| 274 | } |
| 275 | |
| 276 | print_blank(); |
| 277 | |
| 278 | // Check if there are any changes |
| 279 | let has_changes = status.modified_count() > 0 |
| 280 | || status.deleted_count() > 0 |
| 281 | || status.added_count() > 0 |
| 282 | || status.conflicted_count() > 0; |
| 283 | |
| 284 | let has_untracked = status.untracked_count() > 0; |
| 285 | |
| 286 | if !has_changes && !has_untracked { |
| 287 | println!("{}", info("nothing to record, working tree clean")); |
| 288 | return Ok(()); |
| 289 | } |
| 290 | |
| 291 | // Print changes section |
| 292 | if has_changes { |
| 293 | print_section("Changes to be recorded:"); |
| 294 | println!( |
| 295 | " {}", |
| 296 | hint("(use \"atomic restore <file>...\" to discard changes)") |
| 297 | ); |
| 298 | print_blank(); |
| 299 | |
| 300 | // Print added files and directories |
| 301 | for entry in status.added() { |
| 302 | let path_str = entry.path().display().to_string(); |
| 303 | let is_dir = entry.details().map(|d| d == "directory").unwrap_or(false); |
| 304 | if is_dir { |
| 305 | println!("\t{} {}", added("new dir:"), style_path(&path_str)); |
| 306 | } else { |
| 307 | println!("\t{} {}", added("new file:"), style_path(&path_str)); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | // Print modified files |
| 312 | for entry in status.modified() { |
| 313 | let path_str = entry.path().display().to_string(); |
| 314 | println!("\t{} {}", modified("modified:"), style_path(&path_str)); |
| 315 | } |