Skip to content

Commit msg check modification #332

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 2 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ function ci_commit_formatting_run {
# If the common ancestor commit hasn't been found, fetch more.
git merge-base upstream/master HEAD || git fetch upstream master
# For a PR, upstream/master..HEAD ends with a merge commit into master, exclude that one.
python tools/verifygitlog.py -v upstream/master..HEAD --no-merges
python tools/verifygitlog.py --ignore-rebase -v upstream/master..HEAD --no-merges
}

27 changes: 16 additions & 11 deletions tools/verifygitlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,11 @@ def diagnose_subject_line(subject_line, subject_line_format, err):
def verify(sha, err):
verbose("verify", sha)
err.prefix = "commit " + sha + ": "

# Author and committer email.
for line in git_log("%ae%n%ce", sha, "-n1"):
very_verbose("email", line)
if "noreply" in line:
err.error("Unwanted email address: " + line)


# Message body.
raw_body = list(git_log("%B", sha, "-n1"))
verify_message_body(raw_body, err)


def verify_message_body(raw_body, err):

# Empty Message.
if not raw_body:
err.error("Message is empty")
return
Expand All @@ -91,6 +83,19 @@ def verify_message_body(raw_body, err):
if subject_line.startswith(prefix):
verbose("Skipping ignored commit message")
return

# Author and committer email.
for line in git_log("%ae%n%ce", sha, "-n1"):
very_verbose("email", line)
if "noreply" in line:
err.error("Unwanted email address: " + line)


verify_message_body(raw_body, err)


def verify_message_body(raw_body, err):
subject_line = raw_body[0]
very_verbose("subject_line", subject_line)
subject_line_format = r"^[^!]+: [A-Z]+.+ .+\.$"
if not re.match(subject_line_format, subject_line):
Expand Down
Loading