Skip to content

tools/verifygitlog.py: Sync with changes from the main repo. #1007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions tools/verifygitlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def git_log(pretty_format, *args):


def diagnose_subject_line(subject_line, subject_line_format, err):
err.error("Subject line: " + subject_line)
err.error('Subject line: "' + subject_line + '"')
if not subject_line.endswith("."):
err.error('* must end with "."')
if not re.match(r"^[^!]+: ", subject_line):
Expand Down Expand Up @@ -98,20 +98,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)

Expand Down
Loading