Skip to content

Commit

Permalink
test: Accept two letter topics in commit messages
Browse files Browse the repository at this point in the history
Also run the commit-message test locally, so that error can be detected
before pushing to CI.
  • Loading branch information
ffrank committed Mar 1, 2024
1 parent b6b505b commit 9034c4c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/test-commit-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ echo running "$0"
ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${ROOT}" || exit 1

commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)\+[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$'
commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)*[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$'

# Testing the regex itself.

# Correct patterns.
[[ $(echo "ci: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "foo, bar: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "foo: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "f1oo, b2ar: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
Expand Down Expand Up @@ -183,5 +184,13 @@ then
test_commit_message_common_bugs $commit
done
fi
else # assume local branch
commits=$(git log --no-merges --format=%H origin/master..HEAD)
for commit in $commits
do
test_commit_message $commit
test_commit_message_body $commit
test_commit_message_common_bugs $commit
done
fi
echo 'PASS'

0 comments on commit 9034c4c

Please sign in to comment.