Synthesize a commit message from the new Atomic change messages. The change headers are already loaded (via `load_headers(true)` in `run`), so we read the message directly from the entry without redundant `load_change` calls.
(&self, new_history: &[HistoryEntry])
| 364 | /// `run`), so we read the message directly from the entry without |
| 365 | /// redundant `load_change` calls. |
| 366 | fn synthesize_message(&self, new_history: &[HistoryEntry]) -> String { |
| 367 | let mut messages: Vec<String> = Vec::new(); |
| 368 | for entry in new_history.iter().rev() { |
| 369 | if let Some(msg) = entry.message() { |
| 370 | if !msg.is_empty() { |
| 371 | messages.push(msg.to_string()); |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | if messages.is_empty() { |
| 377 | return "Atomic changes".to_string(); |
| 378 | } |
| 379 | |
| 380 | if messages.len() == 1 { |
| 381 | return messages.into_iter().next().unwrap(); |
| 382 | } |
| 383 | |
| 384 | // Multiple messages: bullet list, newest first |
| 385 | let mut result = format!("{} Atomic changes", messages.len()); |
| 386 | for msg in &messages { |
| 387 | let first_line = msg.lines().next().unwrap_or(msg); |
| 388 | result.push_str(&format!("\n\n* {}", first_line)); |
| 389 | } |
| 390 | result |
| 391 | } |
| 392 | |
| 393 | /// Walk git history (first-parent mainline) to find the most recent |
| 394 | /// commit whose `Atomic-View` trailer matches `view` and return its |