test: Add extra commit message tests for some common mistakes

Feel free to add more if we identify them.
This commit is contained in:
James Shubin
2017-11-21 11:05:20 -05:00
parent 5e5bbf4b39
commit 51ce83f20b

View File

@@ -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'