diff --git a/utils/check_code_format.sh b/utils/check_code_format.sh index a6a58796..79947402 100755 --- a/utils/check_code_format.sh +++ b/utils/check_code_format.sh @@ -18,14 +18,16 @@ # # This script assumes to be invoked at the project root directory. -FILES_TO_CHECK=$(git diff --name-only master | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$") +BASE_BRANCH=${1:-master} + +FILES_TO_CHECK=$(git diff --name-only ${BASE_BRANCH} | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$") if [ -z "${FILES_TO_CHECK}" ]; then echo "No source code to check for formatting." exit 0 fi -FORMAT_DIFF=$(git diff -U0 master -- ${FILES_TO_CHECK} | python ./utils/clang-format-diff.py -p1 -style=file) +FORMAT_DIFF=$(git diff -U0 ${BASE_BRANCH} -- ${FILES_TO_CHECK} | python ./utils/clang-format-diff.py -p1 -style=file) if [ -z "${FORMAT_DIFF}" ]; then echo "All source code in PR properly formatted."