mirror of https://github.com/perkeep/perkeep.git
misc/pre-commit.githook: print gofmt to run
Change-Id: I1e177a2cbbc33bae2afc9bcef8c3da387f5bb303
This commit is contained in:
parent
d5fb600ac2
commit
678d7cc45a
|
@ -18,6 +18,7 @@ fi
|
||||||
|
|
||||||
#gofmt and trailing space errors
|
#gofmt and trailing space errors
|
||||||
committed=`git diff-index --cached --name-only HEAD`
|
committed=`git diff-index --cached --name-only HEAD`
|
||||||
|
needFmt=""
|
||||||
for c in $committed
|
for c in $committed
|
||||||
do
|
do
|
||||||
if [ ! -e "$c" ]
|
if [ ! -e "$c" ]
|
||||||
|
@ -31,7 +32,7 @@ do
|
||||||
fmtdiff=`git show ":$c" | gofmt -d 2>&1`
|
fmtdiff=`git show ":$c" | gofmt -d 2>&1`
|
||||||
if [ -n "$fmtdiff" ]
|
if [ -n "$fmtdiff" ]
|
||||||
then
|
then
|
||||||
echo "gofmt needed on "$c
|
needFmt="$needFmt $gofile"
|
||||||
exitstatus=1
|
exitstatus=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -47,6 +48,10 @@ do
|
||||||
done
|
done
|
||||||
if [ "$exitstatus" -ne 0 ]
|
if [ "$exitstatus" -ne 0 ]
|
||||||
then
|
then
|
||||||
|
if [ -n "$needFmt" ]
|
||||||
|
then
|
||||||
|
echo "gofmt -w $needFmt"
|
||||||
|
fi
|
||||||
echo "You can override this check with 'git commit --no-verify'"
|
echo "You can override this check with 'git commit --no-verify'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue