Skip to content

Commit

Permalink
Fix clang-format script when dealing with deleted files.
Browse files Browse the repository at this point in the history
  • Loading branch information
geektoni committed Jul 17, 2017
1 parent 265574b commit 3b1f8ff
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ function check_shogun_style {
echo "Running clang-format-3.8 against branch ${2:-}, with hash $BASE_COMMIT"

COMMIT_FILES=$(git diff --name-only $BASE_COMMIT)
RESULT_OUTPUT="$(git clang-format-3.8 --commit $BASE_COMMIT --diff --binary `which clang-format-3.8` $COMMIT_FILES)"

# Use clang-format only on existent files
LIST=""
for file in $COMMIT_FILES
do
if [ -f $file ]; then
LIST+="$file\n"
fi
done

RESULT_OUTPUT="$(git clang-format-3.8 --commit $BASE_COMMIT --diff --binary `which clang-format-3.8` $LIST)"

if [ "$RESULT_OUTPUT" == "no modified files to format" ] \
|| [ "$RESULT_OUTPUT" == "clang-format-3.8 did not modify any files" ] \
Expand Down

0 comments on commit 3b1f8ff

Please sign in to comment.