Synthesize a commit message from Atomic change messages.
(&self, repo: &Repository, history: &[HistoryEntry])
| 221 | |
| 222 | /// Synthesize a commit message from Atomic change messages. |
| 223 | fn synthesize_message(&self, repo: &Repository, history: &[HistoryEntry]) -> String { |
| 224 | let mut messages: Vec<String> = Vec::new(); |
| 225 | for entry in history.iter().rev().take(20) { |
| 226 | if let Ok(change) = repo.load_change(&entry.hash) { |
| 227 | let msg = change.hashed.header.message.clone(); |
| 228 | if !msg.is_empty() { |
| 229 | messages.push(msg); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if messages.is_empty() { |
| 235 | return "Atomic changes".to_string(); |
| 236 | } |
| 237 | |
| 238 | if messages.len() == 1 { |
| 239 | return messages.into_iter().next().unwrap(); |
| 240 | } |
| 241 | |
| 242 | // Multiple messages: bullet list |
| 243 | let mut result = format!("{} Atomic changes", messages.len()); |
| 244 | for msg in &messages { |
| 245 | let first_line = msg.lines().next().unwrap_or(msg); |
| 246 | result.push_str(&format!("\n\n* {}", first_line)); |
| 247 | } |
| 248 | result |
| 249 | } |
| 250 | |
| 251 | /// Push the current branch to the remote. |
| 252 | fn push_to_remote(&self, git_repo: &GitRepository) -> CliResult<()> { |