Skip to content

Commit 567540d

Browse files
DvdGiessenprojectgus
authored andcommitted
tools/verifygitlog.py: Sync with changes from the main repo.
This includes the following commits: - Allow long co-author and sign-off names. - Disallow a leading slash in commit subject line. - Apply stricter rules on git subject line. - Show invalid commit subjects in quotes. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
1 parent 54d5f7c commit 567540d

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tools/verifygitlog.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def git_log(pretty_format, *args):
4949

5050

5151
def diagnose_subject_line(subject_line, subject_line_format, err):
52-
err.error("Subject line: " + subject_line)
52+
err.error('Subject line: "' + subject_line + '"')
5353
if not subject_line.endswith("."):
5454
err.error('* must end with "."')
5555
if not re.match(r"^[^!]+: ", subject_line):
@@ -98,20 +98,47 @@ def verify_message_body(raw_body, err):
9898
if len(subject_line) >= 73:
9999
err.error("Subject line must be 72 or fewer characters: " + subject_line)
100100

101+
# Do additional checks on the prefix of the subject line.
102+
verify_subject_line_prefix(subject_line.split(": ")[0], err)
103+
101104
# Second one divides subject and body.
102105
if len(raw_body) > 1 and raw_body[1]:
103106
err.error("Second message line must be empty: " + raw_body[1])
104107

105108
# Message body lines.
106109
for line in raw_body[2:]:
107-
# Long lines with URLs are exempt from the line length rule.
108-
if len(line) >= 76 and "://" not in line:
110+
# Long lines with URLs or human names are exempt from the line length rule.
111+
if len(line) >= 76 and not (
112+
"://" in line
113+
or line.startswith("Co-authored-by: ")
114+
or line.startswith("Signed-off-by: ")
115+
):
109116
err.error("Message lines should be 75 or less characters: " + line)
110117

111118
if not raw_body[-1].startswith("Signed-off-by: ") or "@" not in raw_body[-1]:
112119
err.error('Message must be signed-off. Use "git commit -s".')
113120

114121

122+
def verify_subject_line_prefix(prefix, err):
123+
ext = (".c", ".h", ".cpp", ".js", ".rst", ".md")
124+
125+
if prefix.startswith((".", "/")):
126+
err.error('Subject prefix cannot begin with "." or "/".')
127+
128+
if prefix.endswith("/"):
129+
err.error('Subject prefix cannot end with "/".')
130+
131+
if prefix.startswith("ports/"):
132+
err.error(
133+
'Subject prefix cannot begin with "ports/", start with the name of the port instead.'
134+
)
135+
136+
if prefix.endswith(ext):
137+
err.error(
138+
"Subject prefix cannot end with a file extension, use the main part of the filename without the extension."
139+
)
140+
141+
115142
def run(args):
116143
verbose("run", *args)
117144

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