From 3ad0accc4068871bff6fd90de8aa0cb935409e68 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Fri, 24 Jan 2025 08:29:47 +0100 Subject: [PATCH] Do not ignore case on WIP You may legitimately want to use e.g. "fixup" in your commit message. --- .../github/.ci/scripts/validate_commit_message.py.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/github/.ci/scripts/validate_commit_message.py.j2 b/templates/github/.ci/scripts/validate_commit_message.py.j2 index 91935e9d..ba20c3a0 100644 --- a/templates/github/.ci/scripts/validate_commit_message.py.j2 +++ b/templates/github/.ci/scripts/validate_commit_message.py.j2 @@ -19,7 +19,8 @@ BLOCKING_REGEX = [ r"^DO\s*NOT\s*MERGE", r"^EXPERIMENT", r"^FIXUP", - r"Apply suggestions from code review", + r"^fixup!", # This is created by 'git commit --fixup' + r"Apply suggestions from code review", # This usually comes from GitHub ] try: CHANGELOG_EXTS = [ @@ -35,7 +36,11 @@ message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).de if NOISSUE_MARKER in message: sys.exit(f"Do not add '{NOISSUE_MARKER}' in the commit message.") -if any((re.match(pattern, message, re.IGNORECASE) for pattern in BLOCKING_REGEX)): +blocking_matches = [m for m in (re.match(pattern, message) for pattern in BLOCKING_REGEX) if m] +if blocking_matches: + print("Found these phrases in the commit message:") + for m in blocking_matches: + print(" - " + m.group(0)) sys.exit("This PR is not ready for consumption.") g = Github(os.environ.get("GITHUB_TOKEN"))