]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
danger: check that original MR has been merged
authorTom Krizek <tkrizek@isc.org>
Thu, 15 Dec 2022 16:51:24 +0000 (17:51 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 16 Dec 2022 13:22:05 +0000 (14:22 +0100)
When checking a backport MR, ensure that the original MR has been merged
already. This is vital for followup checks that verify commit IDs from
original commits are present in backport commit messages.

(cherry picked from commit 89530f1a1cb2e90b5368605fc317eaed35bf9d1f)

dangerfile.py

index ba24694829ac666d48b6f6eb22c79fc430ddbf3b..c94bb1670cb8eb31c4cc4066f4abaa798b9d5591 100644 (file)
@@ -173,6 +173,8 @@ if not danger.gitlab.mr.milestone:
 # * The Backport MR doesn't have target branch in the merge request title.
 #
 # * The Backport MR doesn't link to the original MR is its description.
+#
+# * The original MR linked to from Backport MR hasn't been merged.
 
 BACKPORT_OF_RE = re.compile(
     r"Backport\s+of.*(merge_requests/|!)([0-9]+)", flags=re.IGNORECASE
@@ -197,6 +199,14 @@ if is_backport:
             "Backport MRs must link to the original MR. Please put "
             "`Backport of MR !XXXX` in the MR description."
         )
+    else:  # backport MR is linked to original MR
+        original_mr_id = backport_desc.groups()[1]
+        original_mr = proj.mergerequests.get(original_mr_id)
+        if original_mr.state != "merged":
+            fail(
+                f"Original MR !{original_mr_id} has not been merged. "
+                "Please re-run `danger` check once it's merged."
+            )
 if not is_backport and not version_labels:
     fail(
         "If this merge request is a backport, set the *Backport* label and "