add ability to check clang-format

This commit is contained in:
Thom Troy
2017-07-05 22:53:57 +01:00
parent 077d498c14
commit b0e13d5bd8
10 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Required because cmake root isn't git root in this example
CLANG_FORMAT_BIN=$1
GIT_ROOT=`git rev-parse --show-toplevel`
pushd ${GIT_ROOT} > /dev/null
git status --porcelain \
| egrep '*\.cpp|*\.h|*\.cxx|*\.hxx|*\.hpp|*\.cc' \
| awk -F " " '{print $NF}' \
| xargs -r ${CLANG_FORMAT_BIN} -style=file -output-replacements-xml \
| grep "replacement offset" 2>&1 > /dev/null
RET=$?
popd > /dev/null
exit ${RET}