Classify an imported commit as normal, merge, or squash.
(info: &ImportedCommitInfo)
| 3534 | |
| 3535 | /// Classify an imported commit as normal, merge, or squash. |
| 3536 | fn classify_commit(info: &ImportedCommitInfo) -> CommitClassification { |
| 3537 | // 1. Multi-parent merge commits |
| 3538 | if info.is_merge { |
| 3539 | return CommitClassification::Merge; |
| 3540 | } |
| 3541 | |
| 3542 | // 2. Atomic-Changes trailer (written by `atomic git push`) |
| 3543 | if let Some(hashes) = parse_atomic_changes_trailer(&info.message) { |
| 3544 | let pr = parse_pr_number(&info.message); |
| 3545 | return CommitClassification::Squash { |
| 3546 | original_hashes: hashes, |
| 3547 | pr_number: pr, |
| 3548 | }; |
| 3549 | } |
| 3550 | |
| 3551 | // 3. Squash merge format (GitHub, GitLab, Azure DevOps) |
| 3552 | if let Some(pr) = parse_squash_merge_format(&info.message) { |
| 3553 | return CommitClassification::Squash { |
| 3554 | original_hashes: Vec::new(), |
| 3555 | pr_number: Some(pr), |
| 3556 | }; |
| 3557 | } |
| 3558 | |
| 3559 | CommitClassification::Normal |
| 3560 | } |
| 3561 | |
| 3562 | /// Parse "Atomic-Changes: HASH1, HASH2, ..." from a commit message. |
| 3563 | fn parse_atomic_changes_trailer(message: &str) -> Option<Vec<String>> { |