summaryrefslogtreecommitdiff
path: root/tools/verifygitlog.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-09-10 12:43:16 +1000
committerDamien George <damien@micropython.org>2025-05-12 13:47:03 +1000
commit61eedbbd1126f895f729a1cf5f9e52e42ddcd471 (patch)
tree8dba5b609384d0a44336f656cb319fc330bc92bd /tools/verifygitlog.py
parent487c94c2532ebb1b346afb92cb79a6b561e064be (diff)
tools/verifygitlog.py: Apply stricter rules on git subject line.
There is a bit of ambiguity as to how the prefix of the git subject line should look like. Eg `py/vm: ...` vs `py/vm.c: ...` (whether the extension should be there or not). This commit makes the existing CI check of the git commit message stricter, by applying extra rules to the prefix, the bit before the : in the subject line. It now checks that the subject prefix: - doesn't start with unwanted bits: ., /, ports/ - doesn't have an extension: .c, .h, .cpp, .js, .rst or .md Full error messages are given when a rule does not pass. This helps to reduce maintainer burden by applying stricter rules, to keep the git commit history consistent. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tools/verifygitlog.py')
-rwxr-xr-xtools/verifygitlog.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/verifygitlog.py b/tools/verifygitlog.py
index 67215d5c5..523461198 100755
--- a/tools/verifygitlog.py
+++ b/tools/verifygitlog.py
@@ -96,6 +96,9 @@ def verify_message_body(raw_body, err):
if len(subject_line) >= 73:
err.error("Subject line must be 72 or fewer characters: " + subject_line)
+ # Do additional checks on the prefix of the subject line.
+ verify_subject_line_prefix(subject_line.split(": ")[0], err)
+
# Second one divides subject and body.
if len(raw_body) > 1 and raw_body[1]:
err.error("Second message line must be empty: " + raw_body[1])
@@ -110,6 +113,26 @@ def verify_message_body(raw_body, err):
err.error('Message must be signed-off. Use "git commit -s".')
+def verify_subject_line_prefix(prefix, err):
+ ext = (".c", ".h", ".cpp", ".js", ".rst", ".md")
+
+ if prefix.startswith("."):
+ err.error('Subject prefix cannot begin with ".".')
+
+ if prefix.endswith("/"):
+ err.error('Subject prefix cannot end with "/".')
+
+ if prefix.startswith("ports/"):
+ err.error(
+ 'Subject prefix cannot begin with "ports/", start with the name of the port instead.'
+ )
+
+ if prefix.endswith(ext):
+ err.error(
+ "Subject prefix cannot end with a file extension, use the main part of the filename without the extension."
+ )
+
+
def run(args):
verbose("run", *args)