githooks

Personal git hooks
git clone git://pollux.codes/git/githooks.git
Log | Files | Refs | README

pre-commit (354B)


      1 #!/bin/sh
      2 
      3 code=0
      4 
      5 for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR | grep "\.py$"` ; do
      6 	tmpfile=`mktemp /tmp/XXXXXX` || exit 1
      7 	cp $file $tmpfile
      8 	black -q $file 2>> /dev/null
      9 	diff -u -p $tmpfile $file 2>> /dev/null
     10 	res=$?
     11 	rm $tmpfile
     12 	if [ $res != 0 ] ; then
     13 		echo "Code style error in $file"
     14 		code=1
     15 	fi
     16 done
     17 
     18 exit $code