blob: 1e382c7fd3c05d07919b701e8fe6c3eae35c9d98 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/bin/bash
# Support old version of astyle 2.04
less -f `which astyle` | grep 2.04
BUG=$?
ASTYLE=$(which astyle)
OPTIONS="--options=./.astylerc"
RETURN=0
FILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h|hpp)$"`
for FILE in $FILES; do
if [ $BUG -ne 0 ]; then
$ASTYLE $OPTIONS < $FILE | cmp -s $FILE -
else
$ASTYLE $OPTIONS < $FILE | head -c -1 | cmp -s $FILE -
fi
if [ $? -ne 0 ]; then
echo "$?" >&2
echo "[!] $FILE does not respect the agreed coding style." >&2
RETURN=1
fi
done
if [ $RETURN -eq 1 ]; then
echo "" >&2
echo "Make sure you have run astyle with options:" >&2
echo "$OPTIONS" >&2
echo "on the file(s)" >&2
fi
exit $RETURN
|