Skip to content

Commit e253e3f

Browse files
committed
github: scripts: fix commit prefix extraction capture in linter
Update commit prefix regex handling in `.github/scripts/commit_prefix_check.py` so subject prefix extraction returns only the prefix token (e.g. `build:`) instead of including trailing content. Changes: - make `PREFIX_RE` capture just the prefix in group 1: - from: `^[a-z0-9_]+:\s+\S` - to: `^([a-z0-9_]+:)\s+\S` - update subject prefix extraction to use `match.group(1)` Why: - previous extraction used `.group()` and could include extra matched text, causing incorrect prefix comparisons during validation. Notes: - `detect_bad_squash()` uses `PREFIX_RE.match(...)` only as a boolean; behavior remains unchanged there. Signed-off-by: Eduardo Silva <[email protected]>
1 parent 18b95a9 commit e253e3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

.github/scripts/commit_prefix_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
repo = Repo(".")
2121

2222
# Regex patterns
23-
PREFIX_RE = re.compile(r"^[a-z0-9_]+:\s+\S", re.IGNORECASE)
23+
PREFIX_RE = re.compile(r"^([a-z0-9_]+:)\s+\S", re.IGNORECASE)
2424
SIGNED_OFF_RE = re.compile(r"Signed-off-by:", re.IGNORECASE)
2525
FENCED_BLOCK_RE = re.compile(
2626
r"""
@@ -176,7 +176,7 @@ def validate_commit(commit):
176176
if not subject_prefix_match:
177177
return False, f"Missing prefix in commit subject: '{first_line}'"
178178

179-
subject_prefix = subject_prefix_match.group()
179+
subject_prefix = subject_prefix_match.group(1)
180180

181181
# Run squash detection (but ignore multi-signoff errors)
182182
bad_squash, reason = detect_bad_squash(body)

0 commit comments

Comments
 (0)