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])
| 576 | /// `run`), so we read the message directly from the entry without |
| 577 | /// redundant `load_change` calls. |
| 578 | fn synthesize_message(&self, new_history: &[HistoryEntry]) -> String { |
| 579 | let mut messages: Vec<String> = Vec::new(); |
| 580 | for entry in new_history.iter().rev() { |
| 581 | if let Some(msg) = entry.message() { |
| 582 | if !msg.is_empty() { |
| 583 | messages.push(msg.to_string()); |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | if messages.is_empty() { |
| 589 | return "Atomic changes".to_string(); |
| 590 | } |
| 591 | |
| 592 | if messages.len() == 1 { |
| 593 | return messages.into_iter().next().unwrap(); |
| 594 | } |
| 595 | |
| 596 | // Multiple messages: bullet list, newest first |
| 597 | let mut result = format!("{} Atomic changes", messages.len()); |
| 598 | for msg in &messages { |
| 599 | let first_line = msg.lines().next().unwrap_or(msg); |
| 600 | result.push_str(&format!("\n\n* {}", first_line)); |
| 601 | } |
| 602 | result |
| 603 | } |
| 604 | |
| 605 | /// Walk git history (first-parent mainline) to find the most recent |
| 606 | /// commit whose `Atomic-View` trailer matches `view` and return its |