Skip to content

Commit 06314fb

Browse files
author
MarcoFalke
committed
Merge #20071: ci, lint: Remove usage of TRAVIS_COMMIT_RANGE
a91ab86 lint: Use TRAVIS_BRANCH in lint-git-commit-check.sh (Fabian Jahr) c11dc99 lint: Don't use TRAVIS_COMMIT_RANGE in whitespace linter (Fabian Jahr) 1b41ce8 lint: Don't use TRAVIS_COMMIT_RANGE for commit-script-check (Fabian Jahr) Pull request description: This is causing problems again, very similar to #19654. UPDATE: This now removes all remaining usages of TRAVIS_COMMIT_RANGE and instead uses TRAVIS_BRANCH for the range, including `lint-git-commit-check` where TRAVIS_COMMIT_RANGE had already been removed. For builds triggered by a pull request, TRAVIS_BRANCH is the name of the branch targeted by the pull request. In the linters there is still a fallback that assumes master as the target branch. ACKs for top commit: sipa: ACK a91ab86. See test I tried in #20075. Tree-SHA512: 1378bdebd5d8787a83fbda5d9999cc9447209423e7f0218fe5eb240e6a32dc1b51d1cd53b4f8cd1f71574d935ac5e22e203dfe09cce17e9976a48416038e1263
2 parents 54fc96f + a91ab86 commit 06314fb

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

ci/lint/06_script.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
export LC_ALL=C
88

99
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
10-
test/lint/commit-script-check.sh $TRAVIS_COMMIT_RANGE
10+
# TRAVIS_BRANCH will be present in a Travis environment. For builds triggered
11+
# by a pull request this is the name of the branch targeted by the pull request.
12+
# https://docs.travis-ci.com/user/environment-variables/
13+
COMMIT_RANGE="$TRAVIS_BRANCH..HEAD"
14+
test/lint/commit-script-check.sh $COMMIT_RANGE
1115
fi
1216

1317
test/lint/git-subtree-check.sh src/crypto/ctaes

test/lint/lint-git-commit-check.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ while getopts "?" opt; do
2323
esac
2424
done
2525

26+
# TRAVIS_BRANCH will be present in a Travis environment. For builds triggered
27+
# by a pull request this is the name of the branch targeted by the pull request.
28+
# https://docs.travis-ci.com/user/environment-variables/
29+
if [ -n "${TRAVIS_BRANCH}" ]; then
30+
COMMIT_RANGE="$TRAVIS_BRANCH..HEAD"
31+
fi
32+
2633
if [ -z "${COMMIT_RANGE}" ]; then
2734
if [ -n "$1" ]; then
2835
COMMIT_RANGE="HEAD~$1...HEAD"
2936
else
37+
# This assumes that the target branch of the pull request will be master.
3038
MERGE_BASE=$(git merge-base HEAD master)
3139
COMMIT_RANGE="$MERGE_BASE..HEAD"
3240
fi

test/lint/lint-whitespace.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,41 @@ while getopts "?" opt; do
1313
case $opt in
1414
?)
1515
echo "Usage: $0 [N]"
16-
echo " TRAVIS_COMMIT_RANGE='<commit range>' $0"
16+
echo " COMMIT_RANGE='<commit range>' $0"
1717
echo " $0 -?"
1818
echo "Checks unstaged changes, the previous N commits, or a commit range."
19-
echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' $0"
19+
echo "COMMIT_RANGE='47ba2c3...ee50c9e' $0"
2020
exit 0
2121
;;
2222
esac
2323
done
2424

25-
if [ -z "${TRAVIS_COMMIT_RANGE}" ]; then
25+
# TRAVIS_BRANCH will be present in a Travis environment. For builds triggered
26+
# by a pull request this is the name of the branch targeted by the pull request.
27+
# https://docs.travis-ci.com/user/environment-variables/
28+
if [ -n "${TRAVIS_BRANCH}" ]; then
29+
COMMIT_RANGE="$TRAVIS_BRANCH..HEAD"
30+
fi
31+
32+
if [ -z "${COMMIT_RANGE}" ]; then
2633
if [ -n "$1" ]; then
27-
TRAVIS_COMMIT_RANGE="HEAD~$1...HEAD"
34+
COMMIT_RANGE="HEAD~$1...HEAD"
2835
else
29-
TRAVIS_COMMIT_RANGE="HEAD"
36+
# This assumes that the target branch of the pull request will be master.
37+
MERGE_BASE=$(git merge-base HEAD master)
38+
COMMIT_RANGE="$MERGE_BASE..HEAD"
3039
fi
3140
fi
3241

3342
showdiff() {
34-
if ! git diff -U0 "${TRAVIS_COMMIT_RANGE}" -- "." ":(exclude)depends/patches/" ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/" ":(exclude)src/qt/locale/"; then
43+
if ! git diff -U0 "${COMMIT_RANGE}" -- "." ":(exclude)depends/patches/" ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/" ":(exclude)src/qt/locale/"; then
3544
echo "Failed to get a diff"
3645
exit 1
3746
fi
3847
}
3948

4049
showcodediff() {
41-
if ! git diff -U0 "${TRAVIS_COMMIT_RANGE}" -- *.cpp *.h *.md *.py *.sh ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/" ":(exclude)src/qt/locale/"; then
50+
if ! git diff -U0 "${COMMIT_RANGE}" -- *.cpp *.h *.md *.py *.sh ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/" ":(exclude)src/qt/locale/"; then
4251
echo "Failed to get a diff"
4352
exit 1
4453
fi

0 commit comments

Comments
 (0)