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

Function parse_commit_message

atomic-cli/src/commands/git/parallel.rs:4541–4564  ·  view source on GitHub ↗

Parse a git commit message into subject and description.

(message: &str)

Source from the content-addressed store, hash-verified

4539
4540/// Parse a git commit message into subject and description.
4541fn parse_commit_message(message: &str) -> (String, Option<String>) {
4542 let lines: Vec<&str> = message.lines().collect();
4543
4544 if lines.is_empty() {
4545 return ("(no message)".to_string(), None);
4546 }
4547
4548 let subject = lines[0].trim().to_string();
4549
4550 let body_lines: Vec<&str> = lines
4551 .iter()
4552 .skip(1)
4553 .skip_while(|line| line.trim().is_empty())
4554 .copied()
4555 .collect();
4556
4557 let description = if body_lines.is_empty() {
4558 None
4559 } else {
4560 Some(body_lines.join("\n").trim().to_string())
4561 };
4562
4563 (subject, description)
4564}
4565
4566// ═══════════════════════════════════════════════════════════════════════════
4567// Tests

Calls 4

skipMethod · 0.80
linesMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45