]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
danger: check version in MR title
authorTom Krizek <tkrizek@isc.org>
Mon, 19 Dec 2022 13:43:16 +0000 (14:43 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 23 Dec 2022 08:53:31 +0000 (09:53 +0100)
Enforce the version indicator to be at the start of the MR title.

(cherry picked from commit d1172e011c32f3708422557ad5fdbee00e6fb7dd)

dangerfile.py

index 2ac0b574f51398f2f2643c36372faafd0a2c154f..f9b2e7ede04bc405d503f79f3ca5a0f28f528e7b 100644 (file)
@@ -172,6 +172,7 @@ if not danger.gitlab.mr.milestone:
 BACKPORT_OF_RE = re.compile(
     r"Backport\s+of.*(merge_requests/|!)([0-9]+)", flags=re.IGNORECASE
 )
+VERSION_LABEL_RE = re.compile(r"v9.([0-9]+)(-S)?")
 backport_desc = BACKPORT_OF_RE.search(danger.gitlab.mr.description)
 version_labels = [l for l in mr_labels if l.startswith("v9.")]
 if is_backport:
@@ -181,11 +182,14 @@ if is_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:
+        minor_ver, edition = VERSION_LABEL_RE.search(version_labels[0]).groups()
+        edition = "" if edition is None else edition
+        title_re = f"^\\[9.{minor_ver}{edition}\\]"
+        match = re.search(title_re, danger.gitlab.mr.title)
+        if match is None:
             fail(
-                "Backport MRs must have their target branch in the "
-                f"title. Please put `{mr_title_version}` in the MR title."
+                "Backport MRs must have their target version in the title. "
+                f"Please put `[9.{minor_ver}{edition}]` at the start of the MR title."
             )
     if backport_desc is None:
         fail(