From: Michał Kępień Date: Mon, 3 Jun 2024 11:07:21 +0000 (+0200) Subject: Warn about auto-generated merge request titles X-Git-Tag: v9.20.0~15^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80ec57f198e5706e653ebe2016f41dc6f856db8c;p=thirdparty%2Fbind9.git 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. --- diff --git a/dangerfile.py b/dangerfile.py index c3f63688b34..5970976e852 100644 --- a/dangerfile.py +++ b/dangerfile.py @@ -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. "