diff --git a/clangify.sh b/clangify.sh index 7e670c6b..bad86ca4 100755 --- a/clangify.sh +++ b/clangify.sh @@ -1,18 +1,22 @@ #!/bin/bash -# This script will run clang-format on all non-3rd-party C++/Header files. +# This script will run clang-format on all modified, non-3rd-party C++/Header files. set -e -if hash clang-format 2>/dev/null; then - find . \( -name "*.cpp" -o -name "*.h" \) \ +if hash clang-format 2>/dev/null && hash git 2>/dev/null; then + files_to_clean=($(git diff --name-only $(git merge-base origin/master HEAD))) + + printf "%s\n" ${files_to_clean[@]} | \ + xargs -I{} find '{}' \( -name "*.cpp" -o -name "*.h" \) \ -not -path "./cockatrice/src/qt-json/*" \ -not -path "./servatrice/src/smtp/*" \ -not -path "./common/sfmt/*" \ -not -path "./oracle/src/zip/*" \ -not -path "./build*/*" \ -exec clang-format -style=file -i {} \; - echo "Repository properly formatted" + echo "Successfully formatted following files:" + printf "%s\n" ${files_to_clean[@]} else - echo "Please install clang-format to use this program" + echo "Please install clang-format and git to use this program" fi