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])
| 321 | /// `run`), so we read the message directly from the entry without |
| 322 | /// redundant `load_change` calls. |
| 323 | fn synthesize_message(&self, new_history: &[HistoryEntry]) -> String { |
| 324 | let mut messages: Vec<String> = Vec::new(); |
| 325 | for entry in new_history.iter().rev() { |
| 326 | if let Some(msg) = entry.message() { |
| 327 | if !msg.is_empty() { |
| 328 | messages.push(msg.to_string()); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if messages.is_empty() { |
| 334 | return "Atomic changes".to_string(); |
| 335 | } |
| 336 | |
| 337 | if messages.len() == 1 { |
| 338 | return messages.into_iter().next().unwrap(); |
| 339 | } |
| 340 | |
| 341 | // Multiple messages: bullet list, newest first |
| 342 | let mut result = format!("{} Atomic changes", messages.len()); |
| 343 | for msg in &messages { |
| 344 | let first_line = msg.lines().next().unwrap_or(msg); |
| 345 | result.push_str(&format!("\n\n* {}", first_line)); |
| 346 | } |
| 347 | result |
| 348 | } |
| 349 | |
| 350 | /// Walk git history (first-parent mainline) to find the most recent |
| 351 | /// commit whose `Atomic-View` trailer matches `view` and return its |