MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / synthesize_message

Method synthesize_message

atomic-cli/src/commands/git/push.rs:223–249  ·  view source on GitHub ↗

Synthesize a commit message from Atomic change messages.

(&self, repo: &Repository, history: &[HistoryEntry])

Source from the content-addressed store, hash-verified

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<()> {

Callers 1

build_commit_messageMethod · 0.80

Calls 10

iterMethod · 0.45
load_changeMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45
unwrapMethod · 0.45
nextMethod · 0.45
into_iterMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected