summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2016-09-12 16:40:09 -0700
committerMartin Thomson <martin.thomson@gmail.com>2016-09-12 16:40:09 -0700
commit0cd5d1c6294b4ebc1474a9aa6afb1079087ceec4 (patch)
tree31535871a6c73b836e8492f6dfe2946a07d564b6
parentbfccf7a87ecaeb2ecc2aa08dde7ca54637343604 (diff)
downloadnss-hg-0cd5d1c6294b4ebc1474a9aa6afb1079087ceec4.tar.gz
Bug 1302272 - Produce more usable output from clang-format failures, r=ttaubert
-rwxr-xr-xautomation/taskcluster/scripts/run_clang_format.sh26
1 files changed, 10 insertions, 16 deletions
diff --git a/automation/taskcluster/scripts/run_clang_format.sh b/automation/taskcluster/scripts/run_clang_format.sh
index bb3fca815..e5607cdf4 100755
--- a/automation/taskcluster/scripts/run_clang_format.sh
+++ b/automation/taskcluster/scripts/run_clang_format.sh
@@ -13,12 +13,6 @@ fi
# Includes a default set of directories.
-apply=false
-if [ $1 = "--apply" ]; then
- apply=true
- shift
-fi
-
if [ $# -gt 0 ]; then
dirs=("$@")
else
@@ -47,15 +41,15 @@ else
)
fi
-STATUS=0
for dir in "${dirs[@]}"; do
- for i in $(find "$dir" -type f \( -name '*.[ch]' -o -name '*.cc' \) -print); do
- if $apply; then
- clang-format -i "$i"
- elif ! clang-format "$i" | diff -Naur "$i" -; then
- echo "Sorry, $i is not formatted properly. Please use clang-format 3.8 on your patch before landing."
- STATUS=1
- fi
- done
+ find "$dir" -type f \( -name '*.[ch]' -o -name '*.cc' \) -exec clang-format -i {} \+
done
-exit $STATUS
+
+TMPFILE=$(mktemp /tmp/$(basename $0).XXXXXX)
+trap 'rm $TMPFILE' exit
+if hg root >/dev/null 2>&1; then
+ hg diff --git "$top" | tee $TMPFILE
+else
+ git -C "$top" diff | tee $TMPFILE
+fi
+[[ ! -s $TMPFILE ]]