From 51ce83f20b832469568aa53b18a2cfad445d0e84 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 21 Nov 2017 11:05:20 -0500 Subject: [PATCH] test: Add extra commit message tests for some common mistakes Feel free to add more if we identify them. --- test/test-commit-message.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test-commit-message.sh b/test/test-commit-message.sh index 6b544c3b..2ca606f4 100755 --- a/test/test-commit-message.sh +++ b/test/test-commit-message.sh @@ -59,6 +59,20 @@ test_commit_message() { fi } +test_commit_message_common_bugs() { + echo "Testing commit message for common bugs $1" + if git log --format=%s $1 | head -n 1 | grep -q "^resource:" + then + echo 'FAIL: Commit message starts with `resource:`, did you mean `resources:` ?' + exit 1 + fi + if git log --format=%s $1 | head -n 1 | grep -q "^tests:" + then + echo 'FAIL: Commit message starts with `tests:`, did you mean `test:` ?' + exit 1 + fi +} + if [[ -n "$TRAVIS_PULL_REQUEST_SHA" ]] then commits=$(git log --format=%H origin/${TRAVIS_BRANCH}..${TRAVIS_PULL_REQUEST_SHA}) @@ -67,6 +81,7 @@ then for commit in $commits do test_commit_message $commit + test_commit_message_common_bugs $commit done fi echo 'PASS'