]> 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 13:22:05 +0000 (14:22 +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.

(cherry picked from commit c617f97784ff898cfea7bbbc6ab6c92eb409009d)

dangerfile.py

index c94bb1670cb8eb31c4cc4066f4abaa798b9d5591..dbad008734b5c0aeb4396661bd63151042b68ad1 100644 (file)
@@ -207,6 +207,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 "