Skip to content

Commit 99c0d1b

Browse files
author
Dane Springmeyer
committed
make clang-tidy script fail if files are modified/fixed automatically
1 parent 34b915a commit 99c0d1b

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

scripts/clang-tidy.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ set -o pipefail
55

66
# https://clang.llvm.org/extra/clang-tidy/
77

8+
: '
9+
10+
Runs clang-tidy on the code in src/
11+
12+
Return `1` if there are files automatically fixed by clang-tidy.
13+
14+
Returns `0` if no fixes by clang-tidy.
15+
16+
TODO: should also return non-zero if clang-tidy emits warnings
17+
or errors about things it cannot automatically fix. However I cannot
18+
figure out how to get this working yet as it seems that clang-tidy
19+
always returns 0 even on errors.
20+
21+
'
22+
823
# to speed up re-runs, only re-create environment if needed
924
if [[ ! -f local.env ]]; then
1025
# automatically setup environment
@@ -43,3 +58,15 @@ fi
4358
cd build
4459
${PATH_TO_CLANG_TIDY_SCRIPT} -fix
4560

61+
# Print list of modified files
62+
dirty=$(git ls-files --modified src/)
63+
64+
if [[ $dirty ]]; then
65+
echo "The following files have been modified:"
66+
echo $dirty
67+
git diff
68+
exit 1
69+
else
70+
exit 0
71+
fi
72+

0 commit comments

Comments
 (0)