2017-03-22 21:18:48 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-22 21:36:52 +02:00
|
|
|
# Lint all commit messages that are newer than upstream/master if running
|
2017-07-31 18:27:32 +02:00
|
|
|
# locally or the commits in the push or PR if in Travis CI.
|
2017-04-22 21:36:52 +02:00
|
|
|
|
2017-03-22 21:18:48 +01:00
|
|
|
# The rules can be found in /.gitlint
|
|
|
|
|
2017-04-26 01:50:16 +02:00
|
|
|
if [ "$TRAVIS" ]; then
|
|
|
|
# Work around https://github.com/travis-ci/travis-ci/issues/4596
|
|
|
|
range="${TRAVIS_COMMIT_RANGE/.../..}"
|
2017-04-22 21:36:52 +02:00
|
|
|
else
|
2017-04-26 01:50:16 +02:00
|
|
|
range="upstream/master..HEAD"
|
2017-03-22 21:18:48 +01:00
|
|
|
fi
|
|
|
|
|
2018-03-02 20:49:46 +01:00
|
|
|
commits=$(git log "$range" | wc -l)
|
|
|
|
if [ "$commits" -gt 0 ]; then
|
|
|
|
# Only run gitlint with non-empty commit lists, to avoid a printed
|
|
|
|
# warning.
|
|
|
|
gitlint --commits "$range"
|
|
|
|
fi
|