Skip to content

Commit fff9d6d

Browse files
authored
Restore style checking on travis (#3080)
1 parent 8428d4a commit fff9d6d

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- brew install clang-format
1818
- brew install swiftformat
1919
script:
20-
- ./scripts/check.sh --test-only $TRAVIS_COMMIT_RANGE
20+
- ./scripts/check.sh --test-only
2121

2222
# The order of builds matters (even though they are run in parallel):
2323
# Travis will schedule them in the same order they are listed here.

scripts/check.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ if [[ ! -t 1 ]]; then
9393
VERBOSE=true
9494
fi
9595

96+
# When travis clones a repo for building, it uses a shallow clone. After the
97+
# first commit on a non-master branch, TRAVIS_COMMIT_RANGE is not set, master
98+
# is not available and we need to compute the START_REVISION from the common
99+
# ancestor of $TRAVIS_COMMIT and origin/master.
100+
if [[ -n "${TRAVIS_COMMIT_RANGE:-}" ]] ; then
101+
START_REVISION="$TRAVIS_COMMIT_RANGE"
102+
elif [[ -n "${TRAVIS_COMMIT:-}" ]] ; then
103+
if ! git rev-parse origin/master >& /dev/null; then
104+
git remote set-branches --add origin master
105+
git fetch origin
106+
fi
107+
START_REVISION=$(git merge-base origin/master "${TRAVIS_COMMIT}")
108+
fi
109+
96110
while [[ $# -gt 0 ]]; do
97111
case "$1" in
98112
--)
@@ -163,19 +177,23 @@ if [[ "${VERBOSE}" == true ]]; then
163177
env | egrep '^TRAVIS_(BRANCH|COMMIT|PULL|REPO)' | sort || true
164178
fi
165179

166-
# When travis clones a repo for building, it uses a shallow clone. After the
167-
# first commit on a non-master branch, TRAVIS_COMMIT_RANGE is not set and
168-
# START_REVISION is "master" instead of a range.
180+
if [[ "${START_REVISION}" == *..* ]]; then
181+
RANGE_START="${START_REVISION/..*/}"
182+
RANGE_END="${START_REVISION/*../}"
169183

170-
# If needed, check if we have access to master and add it to the repo.
171-
if [[ "${START_REVISION}" == "origin/master" ]]; then
184+
# Figure out if we have access to master. If not add it to the repo.
172185
if ! git rev-parse origin/master >& /dev/null; then
173186
git remote set-branches --add origin master
174187
git fetch origin
175188
fi
176-
fi
177189

178-
START_SHA=$(git rev-parse "${START_REVISION}")
190+
NEW_RANGE_START=$(git merge-base origin/master "${RANGE_END}")
191+
START_REVISION="${START_REVISION/$RANGE_START/$NEW_RANGE_START}"
192+
START_SHA="${START_REVISION}"
193+
194+
else
195+
START_SHA=$(git rev-parse "${START_REVISION}")
196+
fi
179197

180198
if [[ "${VERBOSE}" == true ]]; then
181199
echo "START_REVISION=$START_REVISION"

0 commit comments

Comments
 (0)