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

Function parse_commit_message

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

Parse a git commit message into subject and description.

(message: &str)

Source from the content-addressed store, hash-verified

4022
4023/// Parse a git commit message into subject and description.
4024fn parse_commit_message(message: &str) -> (String, Option<String>) {
4025 let lines: Vec<&str> = message.lines().collect();
4026
4027 if lines.is_empty() {
4028 return ("(no message)".to_string(), None);
4029 }
4030
4031 let subject = lines[0].trim().to_string();
4032
4033 let body_lines: Vec<&str> = lines
4034 .iter()
4035 .skip(1)
4036 .skip_while(|line| line.trim().is_empty())
4037 .copied()
4038 .collect();
4039
4040 let description = if body_lines.is_empty() {
4041 None
4042 } else {
4043 Some(body_lines.join("\n").trim().to_string())
4044 };
4045
4046 (subject, description)
4047}
4048
4049// ═══════════════════════════════════════════════════════════════════════════
4050// Tests

Calls 4

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