From 4780b52ea8e2d1f4592e8bb04fe6cc32007ebf96 Mon Sep 17 00:00:00 2001 From: mehrdadn Date: Wed, 15 Jan 2020 11:17:49 -0800 Subject: [PATCH] Polish clang-format and let it run in a local repo (#6793) --- ci/travis/check-git-clang-format-output.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ci/travis/check-git-clang-format-output.sh b/ci/travis/check-git-clang-format-output.sh index 224de1fc3..6dc0b51ca 100755 --- a/ci/travis/check-git-clang-format-output.sh +++ b/ci/travis/check-git-clang-format-output.sh @@ -1,16 +1,16 @@ #!/bin/bash -if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then +if [ -z "${TRAVIS_PULL_REQUEST-}" ] || [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then # Not in a pull request, so compare against parent commit base_commit="HEAD^" - echo "Running clang-format against parent commit $(git rev-parse $base_commit)" + echo "Running clang-format against parent commit $(git rev-parse "$base_commit")" else base_commit="$TRAVIS_BRANCH" - echo "Running clang-format against branch $base_commit, with hash $(git rev-parse $base_commit)" + echo "Running clang-format against branch $base_commit, with hash $(git rev-parse "$base_commit")" fi exclude_regex="(.*thirdparty/|.*redismodule.h|.*.java|.*.jsx?|.*.tsx?)" -output=$(ci/travis/git-clang-format --binary clang-format --commit $base_commit --diff --exclude "$exclude_regex") -if [ "$output" == "no modified files to format" ] || [ "$output" == "clang-format did not modify any files" ] ; then +output="$(ci/travis/git-clang-format --binary clang-format --commit "$base_commit" --diff --exclude "$exclude_regex")" +if [ "$output" = "no modified files to format" ] || [ "$output" = "clang-format did not modify any files" ] ; then echo "clang-format passed." exit 0 else