Classify an imported commit as normal, merge, or squash.
(info: &ImportedCommitInfo)
| 3449 | |
| 3450 | /// Classify an imported commit as normal, merge, or squash. |
| 3451 | fn classify_commit(info: &ImportedCommitInfo) -> CommitClassification { |
| 3452 | // 1. Multi-parent merge commits |
| 3453 | if info.is_merge { |
| 3454 | return CommitClassification::Merge; |
| 3455 | } |
| 3456 | |
| 3457 | // 2. Atomic-Changes trailer (written by `atomic git push`) |
| 3458 | if let Some(hashes) = parse_atomic_changes_trailer(&info.message) { |
| 3459 | let pr = parse_pr_number(&info.message); |
| 3460 | return CommitClassification::Squash { |
| 3461 | original_hashes: hashes, |
| 3462 | pr_number: pr, |
| 3463 | }; |
| 3464 | } |
| 3465 | |
| 3466 | // 3. Squash merge format (GitHub, GitLab, Azure DevOps) |
| 3467 | if let Some(pr) = parse_squash_merge_format(&info.message) { |
| 3468 | return CommitClassification::Squash { |
| 3469 | original_hashes: Vec::new(), |
| 3470 | pr_number: Some(pr), |
| 3471 | }; |
| 3472 | } |
| 3473 | |
| 3474 | CommitClassification::Normal |
| 3475 | } |
| 3476 | |
| 3477 | /// Parse "Atomic-Changes: HASH1, HASH2, ..." from a commit message. |
| 3478 | fn parse_atomic_changes_trailer(message: &str) -> Option<Vec<String>> { |