diff options
author | Pascal Bühler <pabuhler@cisco.com> | 2017-10-09 10:47:27 +0200 |
---|---|---|
committer | Pascal Bühler <pabuhler@cisco.com> | 2017-10-11 16:23:12 +0200 |
commit | 6aef9c0f82a7c0f8e87122769f2f040be89ccdc3 (patch) | |
tree | 1f91f0aff008d64d60648c71ee001c5874dfaf6a /format.sh | |
parent | a6eda52042365fb91c3696a5edfe5b491c2d3cc5 (diff) | |
download | libsrtp2-6aef9c0f82a7c0f8e87122769f2f040be89ccdc3.tar.gz |
Add clang-format check in traivs
If formatting is required the build will fail and
the required diff printed
Currently works against clang-format-3.9.
All linux configurations will run the check on travis,
should consider making a specific configuration for format
checking and letting normal builds finish.
Diffstat (limited to 'format.sh')
-rwxr-xr-x | format.sh | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -3,14 +3,33 @@ # format.sh # # run clang-format on each .c & .h file +# +# assumes git tree is clean when reporting status if [ -z "${CLANG_FORMAT}" ]; then CLANG_FORMAT=clang-format fi -a=`git ls-files | grep "\.h$\|\.c$"` +a=`git ls-files '*.h' '*.c'` for x in $a; do - if [ $x != "config_in.h" ]; then - $CLANG_FORMAT -i -style=file $x - fi + if [ $x != "config_in.h" ]; then + $CLANG_FORMAT -i -style=file $x + fi done + +m=`git ls-files -m` +if [ -n "$m" ]; then + v=`$CLANG_FORMAT -version` + echo "Fromatting required when checking with $v" + echo + echo "The following files required formatting:" + for f in $m; do + echo $f + done + if [ "$1" = "-d" ]; then + echo + git diff + fi + exit 1 +fi +exit 0 |