From 9034c4ced638a67f07ee79409ed5eaa6183d4dc3 Mon Sep 17 00:00:00 2001 From: Felix Frank Date: Sat, 2 Mar 2024 00:11:53 +0100 Subject: [PATCH] test: Accept two letter topics in commit messages Also run the commit-message test locally, so that error can be detected before pushing to CI. --- test/test-commit-message.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test-commit-message.sh b/test/test-commit-message.sh index cdb4bc8f9..f194b4548 100755 --- a/test/test-commit-message.sh +++ b/test/test-commit-message.sh @@ -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 ]] @@ -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'