aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2017-06-12 18:30:47 +0100
committerGitHub <noreply@github.com>2017-06-12 18:30:47 +0100
commit472155837b358ce7d4eab76d126a318f38a1c535 (patch)
treea8b1b177a8c5273eb1ea590414e8033172c012b0 /hooks/pre-commit
parent7cbdab30f45521ce0b578fc7b0fedb7dacb479f8 (diff)
Add misspell and gofmt simplify to the pre-commit hooks (#138)
Diffstat (limited to 'hooks/pre-commit')
-rwxr-xr-xhooks/pre-commit16
1 files changed, 15 insertions, 1 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit
index 2853d60a..523ce0af 100755
--- a/hooks/pre-commit
+++ b/hooks/pre-commit
@@ -3,7 +3,21 @@
set -eu
golint src/...
-go fmt ./src/...
+misspell -error src *.md
+
+# gofmt doesn't exit with an error code if the files don't match the expected
+# format. So we have to run it and see if it outputs anything.
+if gofmt -l -s ./src/ 2>&1 | read
+then
+ echo "Error: not all code had been formatted with gofmt."
+ echo "Fixing the following files"
+ gofmt -s -w -l ./src/
+ echo
+ echo "Please add them to the commit"
+ git status --short
+ exit 1
+fi
+
go tool vet --all --shadow ./src
gocyclo -over 12 src/
gb test