-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
pre-commit
executable file
·34 lines (30 loc) · 1.09 KB
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
GOFMT_FILES=$(gofmt -l .)
if [ -n "${GOFMT_FILES}" ]; then
printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILES}"
exit 1
fi
# comments for public struct and method are auto generated, it does not conform the golint specification,
# currently, disable the golint check.
#
#GOLINT_ERRORS=$(golint ./... | grep -v "Id should be")
#if [ -n "${GOLINT_ERRORS}" ]; then
# printf >&2 'golint failed for the following reasons:\n%s\n\nplease run 'golint ./...' on your changes before committing.\n' "${GOLINT_ERRORS}"
# exit 1
#fi
GOVET_ERRORS=$(go vet ./... 2>&1)
if [ -n "${GOVET_ERRORS}" ]; then
printf >&2 'go vet failed for the following reasons:\n%s\n\nplease run "go tool vet *.go" on your changes before committing.\n' "${GOVET_ERRORS}"
exit 1
fi
# (TODO) enable this when we have test files
#
#if [ -z "${NOTEST}" ]; then
# printf >&2 'Running short tests...\n'
# go test -short -v | egrep 'PASS|ok'
#
# if [ $? -ne 0 ]; then
# printf >&2 'go test failed, please fix before committing.\n'
# exit 1
# fi
#fi