github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/misc/pre-commit.githook (about) 1 #!/usr/bin/env sh 2 3 exitstatus=0 4 5 #third_party imports. 6 cd third_party 7 rewrite=`./rewrite-imports.sh -l` 8 cd .. 9 if [ -n "$rewrite" ] 10 then 11 exitstatus=1 12 for r in $rewrite 13 do 14 echo $r 15 done 16 echo "The above need their imports to be fixed. Use rewrite-imports.sh -w" 17 fi 18 19 #gofmt and trailing space errors 20 committed=`git diff-index --cached --name-only HEAD` 21 for c in $committed 22 do 23 if [ ! -e "$c" ] 24 then 25 continue 26 fi 27 gofile=`echo $c | grep -E '.*\.go$'` 28 javafile=`echo $c | grep -E '.*\.java$'` 29 if [ -n "$gofile" ] 30 then 31 fmtdiff=`git show ":$c" | gofmt -d 2>&1` 32 if [ -n "$fmtdiff" ] 33 then 34 echo "gofmt needed on "$c 35 exitstatus=1 36 fi 37 fi 38 if [ -n "$gofile" -o -n "$javafile" ] 39 then 40 trailspace=`git diff-index --cached --check HEAD $c | grep 'trailing whitespace'` 41 if [ -n "$trailspace" ] 42 then 43 echo $trailspace 44 exitstatus=1 45 fi 46 fi 47 done 48 if [ "$exitstatus" -ne 0 ] 49 then 50 echo "You can override this check with 'git commit --no-verify'" 51 fi 52 53 exit $exitstatus