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])
| 295 | /// `run`), so we read the message directly from the entry without |
| 296 | /// redundant `load_change` calls. |
| 297 | fn synthesize_message(&self, new_history: &[HistoryEntry]) -> String { |
| 298 | let mut messages: Vec<String> = Vec::new(); |
| 299 | for entry in new_history.iter().rev() { |
| 300 | if let Some(msg) = entry.message() { |
| 301 | if !msg.is_empty() { |
| 302 | messages.push(msg.to_string()); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if messages.is_empty() { |
| 308 | return "Atomic changes".to_string(); |
| 309 | } |
| 310 | |
| 311 | if messages.len() == 1 { |
| 312 | return messages.into_iter().next().unwrap(); |
| 313 | } |
| 314 | |
| 315 | // Multiple messages: bullet list, newest first |
| 316 | let mut result = format!("{} Atomic changes", messages.len()); |
| 317 | for msg in &messages { |
| 318 | let first_line = msg.lines().next().unwrap_or(msg); |
| 319 | result.push_str(&format!("\n\n* {}", first_line)); |
| 320 | } |
| 321 | result |
| 322 | } |
| 323 | |
| 324 | /// Walk git history (first-parent mainline) to find the most recent |
| 325 | /// commit whose `Atomic-View` trailer matches `view` and return its |