Compare commits

...

2 Commits

Author SHA1 Message Date
spycrab
f4b0e21ca2 Merge 8e46f6c2f2 into 9ae55884d2 2018-01-17 11:46:33 +00:00
spycrab
8e46f6c2f2 Add linter 2018-01-17 12:40:35 +01:00

22
tools/lint.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Tool for checking for clang-format compliance
# Heavily inspired by: https://github.com/dolphin-emu/dolphin/blob/master/Tools/lint.sh
COMMIT=${1:---cached}
FILES=$(git diff --name-only --diff-filter=ACMRTUXB $COMMIT)
EXIT_CODE=0
for f in ${FILES}; do
# Ignore anything that isn't a source file
if ! echo "$f" | egrep -q "^src.*\.(cpp|h)$"; then
continue
fi
# Check if clang-format and the original differ
if ! clang-format "$f" | diff - "$f"; then
echo "$f violates the coding style, fix listed above"
EXIT_CODE=1
fi
done
exit $EXIT_CODE