2014-06-06 23:40:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
errors=0
|
|
|
|
for file in $(git diff --cached --name-only | grep "\.go"); do
|
2014-06-13 05:03:00 +00:00
|
|
|
diff="$(git show ":${file}" | gofmt -s -d)"
|
2014-06-06 23:40:48 +00:00
|
|
|
if [[ -n "$diff" ]]; then
|
|
|
|
echo "# *** ERROR: *** File ${file} has not been gofmt'd." >> $1
|
|
|
|
errors=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $errors == "1" ]]; then
|
2014-06-13 00:25:46 +00:00
|
|
|
echo "# To fix these errors, run gofmt -s -w <file>." >> $1
|
2014-06-06 23:40:48 +00:00
|
|
|
echo "# If you want to commit in spite of these format errors," >> $1
|
|
|
|
echo "# then delete this line. Otherwise, your commit will be" >> $1
|
|
|
|
echo "# aborted." >> $1
|
|
|
|
fi
|