GRM-20: fix: enforce GRM-N: conventional on master commits and PR titles
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
"""Validate commit messages for GRM.
|
||||
|
||||
Rules:
|
||||
- On master branch: allow anything (merge commits already have task ID).
|
||||
- On feature branches: must use conventional commit format, must NOT include GRM-N prefix.
|
||||
- On feature branches: conventional commits ONLY, must NOT include GRM-N prefix.
|
||||
- On master branch: must follow '<task-id>: <conventional commit>' pattern,
|
||||
e.g. 'GRM-24: fix: resolve timeout'.
|
||||
"""
|
||||
import re
|
||||
import subprocess
|
||||
@@ -41,11 +42,23 @@ def main(args=None) -> None:
|
||||
|
||||
branch = get_branch()
|
||||
|
||||
if branch == "master":
|
||||
return
|
||||
|
||||
subject = first_line(msg)
|
||||
|
||||
if branch == "master":
|
||||
if not TASK_ID_RE.match(subject):
|
||||
print("ERROR: Master branch commits must start with a task ID.")
|
||||
print(" Expected: GRM-N: <conventional commit message>")
|
||||
print(f" Got: {subject}")
|
||||
sys.exit(1)
|
||||
# Strip task-id prefix and validate the remainder as conventional
|
||||
remainder = TASK_ID_RE.sub("", subject).strip()
|
||||
if not CONVENTIONAL_RE.match(remainder):
|
||||
print("ERROR: Master branch commit message must follow conventional format after task ID.")
|
||||
print(" Expected: GRM-N: <type>: <description>")
|
||||
print(f" Got: {subject}")
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
if TASK_ID_RE.match(subject):
|
||||
print("ERROR: Do not include task ID (GRM-N) in feature branch commits.")
|
||||
print(" Task ID will be added automatically on merge via CI.")
|
||||
|
||||
Reference in New Issue
Block a user