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

Function parse_commit_message

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

Parse a git commit message into subject and description.

(message: &str)

Source from the content-addressed store, hash-verified

9679
9680/// Parse a git commit message into subject and description.
9681fn parse_commit_message(message: &str) -> (String, Option<String>) {
9682 let lines: Vec<&str> = message.lines().collect();
9683
9684 if lines.is_empty() {
9685 return ("(no message)".to_string(), None);
9686 }
9687
9688 let subject = lines[0].trim().to_string();
9689
9690 let body_lines: Vec<&str> = lines
9691 .iter()
9692 .skip(1)
9693 .skip_while(|line| line.trim().is_empty())
9694 .copied()
9695 .collect();
9696
9697 let description = if body_lines.is_empty() {
9698 None
9699 } else {
9700 Some(body_lines.join("\n").trim().to_string())
9701 };
9702
9703 (subject, description)
9704}
9705
9706// ═══════════════════════════════════════════════════════════════════════════
9707// Tests

Calls 5

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