From c4feb513be9c768e812e50c8cb139179b7e83565 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sun, 21 Jan 2018 13:48:26 -0800 Subject: style.sh - output unformatted files in test-only and ignore generated config.h (#690) --- scripts/style.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/style.sh b/scripts/style.sh index 96255f9..1b41b13 100755 --- a/scripts/style.sh +++ b/scripts/style.sh @@ -36,6 +36,7 @@ else options="-i" fi +files=$( ( if [[ $# -gt 0 ]]; then if git rev-parse "$1" -- >& /dev/null; then @@ -58,6 +59,9 @@ fi \%/third_party/% d \%/Firestore/Port/% d +# Generated source +\%/Firestore/core/src/firebase/firestore/util/config.h% d + # Sources pulled in by travis bundler \%/vendor/bundle/% d @@ -69,10 +73,18 @@ fi # Format C-ish sources only \%\.(h|m|mm|cc)$% p -' | xargs clang-format -style=file $options \ - | grep " /dev/null +' +) +needs_formatting=false +for f in $files; do + clang-format -style=file $options $f | grep " /dev/null + if [[ "$test_only" = true && $? -ne 1 ]]; then + echo "$f needs formatting." + needs_formatting=true + fi +done -if [[ "$test_only" = true && $? -ne 1 ]]; then +if [[ "$needs_formatting" = true ]]; then echo "Proposed commit is not style compliant." echo "Run scripts/style.sh and git add the result." exit 1 -- cgit v1.2.3