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
|
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" ]]
|
if [[ -n "$TRAVIS_PULL_REQUEST_SHA" ]]
|
||||||
then
|
then
|
||||||
commits=$(git log --format=%H origin/${TRAVIS_BRANCH}..${TRAVIS_PULL_REQUEST_SHA})
|
commits=$(git log --format=%H origin/${TRAVIS_BRANCH}..${TRAVIS_PULL_REQUEST_SHA})
|
||||||
@@ -67,6 +81,7 @@ then
|
|||||||
for commit in $commits
|
for commit in $commits
|
||||||
do
|
do
|
||||||
test_commit_message $commit
|
test_commit_message $commit
|
||||||
|
test_commit_message_common_bugs $commit
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo 'PASS'
|
echo 'PASS'
|
||||||
|
|||||||
Reference in New Issue
Block a user