Skip to content

Commit d31a3ae

Browse files
committed
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>
1 parent 487c94c commit d31a3ae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/verifygitlog.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def verify_message_body(raw_body, err):
9696
if len(subject_line) >= 73:
9797
err.error("Subject line must be 72 or fewer characters: " + subject_line)
9898

99+
# Do additional checks on the prefix of the subject line.
100+
verify_subject_line_prefix(subject_line.split(": ")[0], err)
101+
99102
# Second one divides subject and body.
100103
if len(raw_body) > 1 and raw_body[1]:
101104
err.error("Second message line must be empty: " + raw_body[1])
@@ -110,6 +113,22 @@ def verify_message_body(raw_body, err):
110113
err.error('Message must be signed-off. Use "git commit -s".')
111114

112115

116+
def verify_subject_line_prefix(prefix, err):
117+
ext = (".c", ".h", ".cpp", ".js", ".rst", ".md")
118+
119+
if prefix.startswith("."):
120+
err.error('Subject prefix cannot begin with ".".')
121+
122+
if prefix.endswith("/"):
123+
err.error('Subject prefix cannot end with "/".')
124+
125+
if prefix.startswith("ports/"):
126+
err.error('Subject prefix cannot begin with "ports/", start with the name of the port instead.')
127+
128+
if prefix.endswith(ext):
129+
err.error("Subject prefix cannot end with a file extension, use the main part of the filename without the extension.")
130+
131+
113132
def run(args):
114133
verbose("run", *args)
115134

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy