aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-29 10:30:10 +0000
committerng0 <ng0@n0.is>2019-09-29 10:30:10 +0000
commitdd298ca059ed935560cccfa020127c93b4d3f823 (patch)
tree97d5330a31bd61df24ffcca8efed92107150e889 /contrib
parentf5759dbc478ddf83b8a1d31d1580c845b9480633 (diff)
downloadgnunet-dd298ca059ed935560cccfa020127c93b4d3f823.tar.gz
gnunet-dd298ca059ed935560cccfa020127c93b4d3f823.zip
add precommit hook example
Diffstat (limited to 'contrib')
-rw-r--r--contrib/uncrustify_precommit34
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
new file mode 100644
index 000000000..bf7bac4ef
--- /dev/null
+++ b/contrib/uncrustify_precommit
@@ -0,0 +1,34 @@
1#!/bin/sh
2
3# use as .git/hooks/pre-commit
4
5exec 1>&2
6
7RET=0
8
9changed=$(git diff --cached --name-only)
10crustified=""
11
12for f in $changed;
13do
14 # compare result of uncrustify with changes
15 #
16 # only change any of the invocations here if
17 # they are portable across all cmp and shell
18 # implementations!
19 uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f -
20 if test $? = 1 ;
21 then
22 crustified=" $crustified $f"
23 RET=1
24 fi
25done
26
27if [ $RET = 1 ];
28then
29 echo "Run"
30 echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
31 echo "before commiting."
32fi
33
34exit $RET