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

Function parse_squash_merge_format

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

Detect squash merge format from various Git forges. Supported formats: - GitHub: `title (#42)\n\n* commit msg 1\n* commit msg 2` - GitLab: `title\n\nSee merge request group/project!42` - Azure DevOps: `Merged PR 42: title\n\n...`

(message: &str)

Source from the content-addressed store, hash-verified

8553/// - GitLab: `title\n\nSee merge request group/project!42`
8554/// - Azure DevOps: `Merged PR 42: title\n\n...`
8555fn parse_squash_merge_format(message: &str) -> Option<u32> {
8556 let lines: Vec<&str> = message.lines().collect();
8557 if lines.len() < 2 {
8558 return None;
8559 }
8560
8561 // GitHub: first line has (#N), followed by blank line + bullet points
8562 if let Some(pr) = parse_pr_number(lines[0]) {
8563 if lines.len() >= 3 {
8564 let has_bullets = lines[2..].iter().any(|l| l.trim().starts_with("* "));
8565 if has_bullets {
8566 return Some(pr);
8567 }
8568 }
8569 }
8570
8571 // GitLab: body contains "See merge request ...!N"
8572 for line in &lines[1..] {
8573 if line.contains("See merge request") {
8574 return parse_pr_number(line);
8575 }
8576 }
8577
8578 // Azure DevOps: "Merged PR N: title"
8579 if lines[0].starts_with("Merged PR ") {
8580 return parse_pr_number(lines[0]);
8581 }
8582
8583 None
8584}
8585
8586// ═══════════════════════════════════════════════════════════════════════
8587// Free Functions for Parallel Parsing

Callers 3

compileMethod · 0.85
classify_commitFunction · 0.85

Calls 6

parse_pr_numberFunction · 0.85
collectMethod · 0.45
linesMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected