GValue: add overflow checking for py -> gint; forward marshaling exceptions
[pygobject.git] / pre-commit.hook
blob139793328875e2fd401164af797167836e2becd2
1 #!/bin/bash
3 # Check that the code follows a consistant code style
6 # Check for existence of astyle, and error out if not present.
7 if ! builtin type -P astyle; then
8 echo "PyGI git pre-commit hook:"
9 echo "Did not find astyle, please install it before continuing."
10 exit 1
13 ASTYLE_PARAMETERS="-p -d -c -S -U -M60"
15 echo "--Checking style--"
16 for file in `git-diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$"` ; do
17 # nf is the temporary checkout. This makes sure we check against the
18 # revision in the index (and not the checked out version).
19 nf=`git checkout-index --temp ${file} | cut -f 1`
20 newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1
21 astyle ${ASTYLE_PARAMETERS} < $nf > $newfile 2>> /dev/null
22 diff -u -p "${nf}" "${newfile}"
23 r=$?
24 rm "${newfile}"
25 rm "${nf}"
26 if [ $r != 0 ] ; then
27 echo "================================================================================================="
28 echo " Code style error in: $file "
29 echo " "
30 echo " Please fix before committing. Don't forget to run git add before trying to commit again. "
31 echo " If the whole file is to be committed, this should work (run from the top-level directory): "
32 echo " "
33 echo " astyle ${ASTYLE_PARAMETERS} $file; git add $file; git commit"
34 echo " "
35 echo "================================================================================================="
36 exit 1
38 done
39 echo "--Checking style pass--"