test: Add extra commit message tests for some common mistakes
Feel free to add more if we identify them.
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user