]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
danger: check backport commits for original commit IDs
authorTom Krizek <tkrizek@isc.org>
Thu, 15 Dec 2022 16:52:52 +0000 (17:52 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 16 Dec 2022 12:37:12 +0000 (13:37 +0100)
A full backport must have all the commit from the original MR and the
original commit IDs must be referenced in the backport commit messages.

If the criteria above is not met, the MR should be marked as a partial
backport. In that case, any discrepencies are only logged as informative
messages rather than failures.

dangerfile.py

index de7a6cef0ca81f93fcb7b626dce02afdbff18057..a73e6259c8e8e41e41cf5c01827aa616eba5f8e1 100644 (file)
@@ -209,6 +209,28 @@ if is_backport:
                 f"Original MR !{original_mr_id} has not been merged. "
                 "Please re-run `danger` check once it's merged."
             )
+        else:  # check for commit IDs once original MR is merged
+            original_mr_commits = list(original_mr.commits(all=True))
+            backport_mr_commits = list(mr.commits(all=True))
+            for orig_commit in original_mr_commits:
+                for backport_commit in backport_mr_commits:
+                    if orig_commit.id in backport_commit.message:
+                        break
+                else:
+                    msg = (
+                        f"Commit {orig_commit.id} from original MR !{original_mr_id} "
+                        "is not referenced in any of the backport commits."
+                    )
+                    if not is_full_backport:
+                        message(msg)
+                    else:
+                        msg += (
+                            " Please use `-x` when cherry-picking to include "
+                            "the full original commit ID. Alternately, use the "
+                            "`Backport::Partial` label if not all original "
+                            "commits are meant to be backported."
+                        )
+                        fail(msg)
 if not is_backport and not version_labels:
     fail(
         "If this merge request is a backport, set the *Backport* label and "