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

Function parse_commit_message

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

Parse a git commit message into subject and description.

(message: &str)

Source from the content-addressed store, hash-verified

4140
4141/// Parse a git commit message into subject and description.
4142fn parse_commit_message(message: &str) -> (String, Option<String>) {
4143 let lines: Vec<&str> = message.lines().collect();
4144
4145 if lines.is_empty() {
4146 return ("(no message)".to_string(), None);
4147 }
4148
4149 let subject = lines[0].trim().to_string();
4150
4151 let body_lines: Vec<&str> = lines
4152 .iter()
4153 .skip(1)
4154 .skip_while(|line| line.trim().is_empty())
4155 .copied()
4156 .collect();
4157
4158 let description = if body_lines.is_empty() {
4159 None
4160 } else {
4161 Some(body_lines.join("\n").trim().to_string())
4162 };
4163
4164 (subject, description)
4165}
4166
4167// ═══════════════════════════════════════════════════════════════════════════
4168// Tests

Calls 4

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