]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
danger: ensure target branch is in the MR title
authorTom Krizek <tkrizek@isc.org>
Thu, 15 Dec 2022 16:45:54 +0000 (17:45 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 16 Dec 2022 12:37:11 +0000 (13:37 +0100)
Having the MR title clearly marked in its title can be very useful when
looking through older issues/MRs.

This check also ensures that the version from the version label matches
the proper version branch (i.e. v9.16 must be marked with [v9_16]).

dangerfile.py

index 8b1a82153430f38f3f03689930540f92bda7b3e7..365fe01a1c2e887065563bc7216a8f4aaa608c8a 100644 (file)
@@ -171,13 +171,23 @@ if not danger.gitlab.mr.milestone:
 # * The MR is not marked as "Backport" nor any version label is set.  (If the
 #   merge request is not a backport, version labels are used for indicating
 #   backporting preferences.)
+#
+# * The Backport MR doesn't have target branch in the merge request title.
 
 version_labels = [l for l in mr_labels if l.startswith("v9.")]
-if is_backport and len(version_labels) != 1:
-    fail(
-        "This MR was marked as *Backport*. "
-        "Please also set exactly one version label (*v9.x*)."
-    )
+if is_backport:
+    if len(version_labels) != 1:
+        fail(
+            "This MR was marked as *Backport*. "
+            "Please also set exactly one version label (*v9.x*)."
+        )
+    else:
+        mr_title_version = f"[{version_labels[0].replace('.', '_')}]"
+        if mr_title_version not in danger.gitlab.mr.title:
+            fail(
+                "Backport MRs must have their target branch in the "
+                f"title. Please put `{mr_title_version}` in the MR title."
+            )
 if not is_backport and not version_labels:
     fail(
         "If this merge request is a backport, set the *Backport* label and "