aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-10-03 21:43:37 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-10-03 21:56:15 +0200
commita91ab86fae91d416d664d19d2f482a8d19c115a6 (patch)
treee3ae3001f10ec30b3179bdbd9a4bf593865bd0fd /test
parentc11dc995c98e908dfd9cea64d4b34329b1dbb5c6 (diff)
lint: Use TRAVIS_BRANCH in lint-git-commit-check.sh
Diffstat (limited to 'test')
-rwxr-xr-xtest/lint/lint-git-commit-check.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/lint/lint-git-commit-check.sh b/test/lint/lint-git-commit-check.sh
index 8947f67bf6..ecaad215c4 100755
--- a/test/lint/lint-git-commit-check.sh
+++ b/test/lint/lint-git-commit-check.sh
@@ -23,10 +23,18 @@ while getopts "?" opt; do
esac
done
+# TRAVIS_BRANCH will be present in a Travis environment. For builds triggered
+# by a pull request this is the name of the branch targeted by the pull request.
+# https://docs.travis-ci.com/user/environment-variables/
+if [ -n "${TRAVIS_BRANCH}" ]; then
+ COMMIT_RANGE="$TRAVIS_BRANCH..HEAD"
+fi
+
if [ -z "${COMMIT_RANGE}" ]; then
if [ -n "$1" ]; then
COMMIT_RANGE="HEAD~$1...HEAD"
else
+ # This assumes that the target branch of the pull request will be master.
MERGE_BASE=$(git merge-base HEAD master)
COMMIT_RANGE="$MERGE_BASE..HEAD"
fi