]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Update issue closing regex in dangerfile.py
authorAndoni Duarte Pintado <andoni@isc.org>
Wed, 2 Apr 2025 12:14:36 +0000 (14:14 +0200)
committerAndoni Duarte <andoni@isc.org>
Wed, 2 Apr 2025 13:42:45 +0000 (13:42 +0000)
Update the regular expression used for extracting references to GitLab
issues closed by a given merge request so that it is identical to the
one used by GitLab [1].

See also isc-projects/bind9-qa!41

[1] https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern

(cherry picked from commit 5298d0fcb8012ec805d632bef34302a168cc3c87)

dangerfile.py

index 79aa9c04aafbe86882d9c7af9ffa4b0381b43162..b6851be7a574df5510cec473f01e3d66969d7b8a 100644 (file)
@@ -44,7 +44,12 @@ def lines_containing(lines, string):
 
 changes_issue_or_mr_id_regex = re.compile(rb"\[(GL [#!]|RT #)[0-9]+\]")
 rdata_regex = re.compile(r"lib/dns/rdata/")
-mr_issue_link_regex = re.compile(r"^(Closes|Fixes):?\s*[^\n]*#[0-9]+", re.MULTILINE)
+
+# Source: https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern
+ISSUE_CLOSING_REGEX = r"\b((?:[Cc]los(?:e[sd]?|ing)|\b[Ff]ix(?:e[sd]|ing)?|\b[Rr]esolv(?:e[sd]?|ing)|\b[Ii]mplement(?:s|ed|ing)?)(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?: *,? +and +| *,? *)?)|([A-Z][A-Z0-9_]+-\d+))+)"
+ISSUE_REF = r"(?P<prefix>(isc-projects/bind9)?#|https://gitlab\.isc\.org/isc-projects/bind9/-/issues/)(?P<id>[0-9]+)"
+full_regex = ISSUE_CLOSING_REGEX.replace("%{issue_ref}", ISSUE_REF)
+mr_issue_link_regex = re.compile(full_regex, re.IGNORECASE | re.MULTILINE)
 
 modified_files = danger.git.modified_files
 affected_files = (