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
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