avif/gofmt-staged.sh

19 lines
349 B
Bash
Raw Normal View History

2019-03-17 12:13:37 +00:00
#!/bin/sh
# https://github.com/edsrzf/gofmt-git-hook
IFS='
'
exitcode=0
for file in `git diff --cached --name-only --diff-filter=ACM | grep '\.go$'`
do
output=`gofmt -w "$file"`
if test -n "$output"
then
# any output is a syntax error
echo >&2 "$output"
exitcode=1
fi
git add "$file"
done
exit $exitcode