Skip to content
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

Limit line length in commit message body to 72 characters #325

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions tests/verify_commit_messages.bats
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ commit_apply_fixture_and_run() {
@test "verify_commit_messages/verify_commit_messages.sh: body too long" {
commit_apply_fixture_and_run too-long-body.patch
assert_failure
assert_output "${shorthash}*error*The line #3 has more than 132 characters (found: 181)"
assert_output "${shorthash}*error*The line #3 has more than 72 characters (found: 181)"
}

@test "verify_commit_messages/verify_commit_messages.sh: backslash ended lines" {
commit_apply_fixture_and_run backslash-ended-lines.patch
assert_failure
refute_output "#3"
refute_output "#5"
assert_output "${shorthash}*error*The line #7 has more than 132 characters (found: 141)"
assert_output "${shorthash}*error*The line #7 has more than 72 characters (found: 141)"
}

@test "verify_commit_messages/verify_commit_messages.sh: AMOS bad syntax" {
Expand Down
8 changes: 4 additions & 4 deletions verify_commit_messages/verify_commit_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# COMMIT (short) * LEVEL (error or warning) * DESCRIPTION (details)
# Example:
# 1234abcd*error*Commit messages does not start with issue code.
# 2345bcde*warning*Body line too long (184 > 132).
# 2345bcde*warning*Body line too long (184 > 72).
# 2345cdef*error*Subject line too long (75 > 72).

# Don't be strict. Script has own error control handle
Expand Down Expand Up @@ -200,10 +200,10 @@ for c in ${commits}; do
fi
# check rest of lines
else
# verify 3rd and following lines are <= 132 chars long. Warn.
# verify 3rd and following lines are <= 72 chars long. Warn.
len=$(echo "${line}" | wc -c)
if [[ ${len} -gt 132 ]]; then
echo "${c}*error*The line #${currentline} has more than 132 characters (found: ${len})"
if [[ ${len} -gt 72 ]]; then
echo "${c}*error*The line #${currentline} has more than 72 characters (found: ${len})"
numproblems=$((numproblems+1))
fi
fi
Expand Down
Loading