2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00

danger: ensure target branch is in the MR title

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]).
This commit is contained in:
Tom Krizek 2022-12-15 17:45:54 +01:00
parent 1c0c1ba8b9
commit 14b027cf83
No known key found for this signature in database
GPG Key ID: 01623B9B652A20A7

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