[travis] check/fix EOF newline on pretty/pretty-check (#3671)

This commit is contained in:
Jonathan Hui
2019-03-12 10:46:58 -07:00
committed by GitHub
parent 498034fba5
commit 92e4d89f64
2 changed files with 35 additions and 2 deletions
+15 -1
View File
@@ -35,7 +35,21 @@
set -x
die() {
echo " *** ERROR: " $*
exit 1
}
# from `man diff`:
# Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
$(dirname "$0")/clang-format.sh -style=file $@ | diff -u $@ -
$(dirname "$0")/clang-format.sh -style=file $@ | diff -u $@ - || die
for arg; do true; done
file=$arg
[ -n "$(tail -c1 $file)" ] && {
echo " *** ERROR: Missing EOF newline: " $file
exit 1
}
exit 0
+20 -1
View File
@@ -48,4 +48,23 @@ else
die "clang-format 6.0 required"
fi
clang-format $@
clang-format $@ || die
# ensure EOF newline
REPLACE=no
for arg
do
case $arg in
-i)
REPLACE=yes
;;
esac
done
file=$arg
[ $REPLACE != yes ] || {
[ -n "$(tail -c1 $file)" ] && echo >> $file
}
exit 0