diff --git a/.travis.yml b/.travis.yml index 5039d8ec..6448fbac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,9 @@ matrix: env: TARGET=debug STATIC_CHECKS=yes addons: apt: - sources: - - llvm-toolchain-xenial-6.0 packages: - [scons, pkg-config, build-essential, p7zip-full, clang-format-6.0] + - clang-format-8 + - [scons, pkg-config, build-essential, p7zip-full] - name: Linux Release os: linux @@ -30,7 +29,7 @@ matrix: addons: apt: packages: - [scons, pkg-config, build-essential, p7zip-full] + - [scons, pkg-config, build-essential, p7zip-full] env: TARGET=release - name: macOS Debug diff --git a/misc/travis/clang-format.sh b/misc/travis/clang-format.sh index ee4d0b2a..5a41fccf 100755 --- a/misc/travis/clang-format.sh +++ b/misc/travis/clang-format.sh @@ -1,17 +1,25 @@ #!/bin/sh -CLANG_FORMAT=clang-format-6.0 +CLANG_FORMAT=clang-format-8 if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - # Check the whole commit range against $TRAVIS_BRANCH, the base merge branch - # We could use $TRAVIS_COMMIT_RANGE but it doesn't play well with force pushes - RANGE="$(git rev-parse $TRAVIS_BRANCH) HEAD" + # Travis only clones the PR branch and uses its HEAD commit as detached HEAD, + # so it's problematic when we want an exact commit range for format checks. + # We fetch upstream to ensure that we have the proper references to resolve. + # Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR + # updates, as it only includes changes since the previous state of the PR. + if [ -z "$(git remote | grep upstream)" ]; then + git remote add upstream https://github.com/godotengine/godot-cpp \ + --no-tags -f -t $TRAVIS_BRANCH + fi + RANGE="upstream/$TRAVIS_BRANCH HEAD" else - # Test only the last commit + # Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support + # force pushes. RANGE=HEAD fi -FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$") +FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$") echo "Checking files:\n$FILES" # create a random filename to store our generated patch