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

Warn about auto-generated merge request titles

Merge request titles auto-generated by GitLab are often a source of
confusion regarding the actual contents of a given merge request.  Warn
for merge requests containing titles that look like auto-generated ones.
This commit is contained in:
Michał Kępień 2024-06-03 13:07:21 +02:00
parent 09851e6230
commit 80ec57f198
No known key found for this signature in database

View File

@ -51,6 +51,7 @@ modified_files = danger.git.modified_files
affected_files = (
danger.git.modified_files + danger.git.created_files + danger.git.deleted_files
)
mr_title = danger.gitlab.mr.title
mr_labels = danger.gitlab.mr.labels
source_branch = danger.gitlab.mr.source_branch
target_branch = danger.gitlab.mr.target_branch
@ -64,6 +65,19 @@ gl = gitlab.Gitlab(
proj = gl.projects.get(os.environ["CI_PROJECT_ID"])
mr = proj.mergerequests.get(os.environ["CI_MERGE_REQUEST_IID"])
###############################################################################
# MERGE REQUEST INFORMATION
###############################################################################
#
# - WARN if the merge request's title looks like an auto-generated one.
if mr_title.replace("Draft: ", "").startswith('Resolve "'):
warn(
f"This merge request's title (`{mr_title}`) looks like an "
"auto-generated one. Please change it so that it accurately "
"describes the changes contained in this merge request."
)
###############################################################################
# BRANCH NAME
###############################################################################
@ -221,7 +235,7 @@ if is_backport:
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)
match = re.search(title_re, mr_title)
if match is None:
fail(
"Backport MRs must have their target version in the title. "