]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
danger: support partial backport label
authorTom Krizek <tkrizek@isc.org>
Thu, 15 Dec 2022 16:39:58 +0000 (17:39 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 16 Dec 2022 13:26:36 +0000 (14:26 +0100)
Treat the Backport::Partial label as a backport as well.

(cherry picked from commit 1c0c1ba8b9a280c53dd0a40141e2dd69960359b9)

dangerfile.py

index f9db5bd7d7eac97be9030608a5b461dc3513ba8c..50cf53161d8600d4c3337cacdd4c5ae85a92baf0 100644 (file)
@@ -34,6 +34,8 @@ release_notes_regex = re.compile(r'doc/(arm|notes)/notes-.*\.(rst|xml)')
 modified_files = danger.git.modified_files
 mr_labels = danger.gitlab.mr.labels
 target_branch = danger.gitlab.mr.target_branch
+is_backport = "Backport" in mr_labels or "Backport::Partial" in mr_labels
+is_full_backport = is_backport and "Backport::Partial" not in mr_labels
 
 ###############################################################################
 # COMMIT MESSAGES
@@ -111,30 +113,33 @@ if not danger.gitlab.mr.milestone:
     fail('Please assign this merge request to a milestone.')
 
 ###############################################################################
-# VERSION LABELS
+# BACKPORT & VERSION LABELS
 ###############################################################################
 #
 # FAIL if any of the following is true for the merge request:
 #
-# * The "Backport" label is set and the number of version labels set is
+# * The MR is marked as Backport and the number of version labels set is
 #   different than 1.  (For backports, the version label is used for indicating
 #   its target branch.  This is a rather ugly attempt to address a UI
 #   deficiency - the target branch for each MR is not visible on milestone
 #   dashboards.)
 #
-# * Neither the "Backport" label nor any version label is set.  (If the merge
-#   request is not a backport, version labels are used for indicating
+# * 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.)
 
-backport_label_set = 'Backport' in mr_labels
-version_labels = [l for l in mr_labels if l.startswith('v9.')]
-if backport_label_set and len(version_labels) != 1:
-    fail('The *Backport* label is set for this merge request. '
-         'Please also set exactly one version label (*v9.x*).')
-if not backport_label_set and not version_labels:
-    fail('If this merge request is a backport, set the *Backport* label and '
-         'a single version label (*v9.x*) indicating the target branch. '
-         'If not, set version labels for all targeted backport branches.')
+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 not is_backport and not version_labels:
+    fail(
+        "If this merge request is a backport, set the *Backport* label and "
+        "a single version label (*v9.x*) indicating the target branch. "
+        "If not, set version labels for all targeted backport branches."
+    )
 
 ###############################################################################
 # OTHER LABELS