summaryrefslogtreecommitdiffstatshomepage
path: root/tools/verifygitlog.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/verifygitlog.py')
-rwxr-xr-xtools/verifygitlog.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/verifygitlog.py b/tools/verifygitlog.py
index 67215d5c5d..dba6ebd6de 100755
--- a/tools/verifygitlog.py
+++ b/tools/verifygitlog.py
@@ -96,20 +96,47 @@ 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])
# Message body lines.
for line in raw_body[2:]:
- # Long lines with URLs are exempt from the line length rule.
- if len(line) >= 76 and "://" not in line:
+ # Long lines with URLs or human names are exempt from the line length rule.
+ if len(line) >= 76 and not (
+ "://" in line
+ or line.startswith("Co-authored-by: ")
+ or line.startswith("Signed-off-by: ")
+ ):
err.error("Message lines should be 75 or less characters: " + line)
if not raw_body[-1].startswith("Signed-off-by: ") or "@" not in raw_body[-1]:
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 "." or "/".')
+
+ 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)