exchange/contrib/uncrustify_precommit

35 lines
696 B
Plaintext
Raw Permalink Normal View History

2019-10-05 15:12:11 +02:00
#!/bin/sh
# use as .git/hooks/pre-commit
exec 1>&2
2019-10-05 15:12:11 +02:00
RET=0
2023-05-13 22:00:04 +02:00
changed=$(git diff --cached --name-only | grep -v mustach | grep -v templating/test./)
2019-10-05 15:12:11 +02:00
crustified=""
for f in $changed;
do
if echo $f | grep \\.[c,h]\$ > /dev/null
then
# compare result of uncrustify with changes
#
# only change any of the invocations here if
# they are portable across all cmp and shell
# implementations !
uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f -
if test $? = 1 ;
then
crustified=" $crustified $f"
RET=1
fi
fi
done
if [ $RET = 1 ];
then
echo "Run"
2023-05-13 22:00:04 +02:00
echo "uncrustify --replace -c uncrustify.cfg ${crustified}"
2020-07-22 23:56:52 +02:00
echo "before committing."
2019-10-05 15:12:11 +02:00
fi
exit $RET