Classify an imported commit as normal, merge, or squash.
(info: &ImportedCommitInfo)
| 3904 | |
| 3905 | /// Classify an imported commit as normal, merge, or squash. |
| 3906 | fn classify_commit(info: &ImportedCommitInfo) -> CommitClassification { |
| 3907 | // 1. Multi-parent merge commits |
| 3908 | if info.is_merge { |
| 3909 | return CommitClassification::Merge; |
| 3910 | } |
| 3911 | |
| 3912 | // 2. Atomic-Changes trailer (written by `atomic git push`) |
| 3913 | if let Some(hashes) = parse_atomic_changes_trailer(&info.message) { |
| 3914 | let pr = parse_pr_number(&info.message); |
| 3915 | return CommitClassification::Squash { |
| 3916 | original_hashes: hashes, |
| 3917 | pr_number: pr, |
| 3918 | }; |
| 3919 | } |
| 3920 | |
| 3921 | // 3. Squash merge format (GitHub, GitLab, Azure DevOps) |
| 3922 | if let Some(pr) = parse_squash_merge_format(&info.message) { |
| 3923 | return CommitClassification::Squash { |
| 3924 | original_hashes: Vec::new(), |
| 3925 | pr_number: Some(pr), |
| 3926 | }; |
| 3927 | } |
| 3928 | |
| 3929 | CommitClassification::Normal |
| 3930 | } |
| 3931 | |
| 3932 | /// Split the value of a single `Atomic-Changes:` trailer (the text after the |
| 3933 | /// colon) into individual, non-empty change hashes. |