-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.sh
36 lines (28 loc) · 948 Bytes
/
hook.sh
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
35
36
#!/usr/bin/env bash
set -e
if hash md5deep 2>/dev/null; then
echo "Has MD5Deep"
else
echo "Please install md5deep using brew install hashdeep"
exit 5
fi
if hash golint 2>/dev/null; then
echo "Has golint"
else
go get -u golang.org/x/lint/golint
fi
md5deep -r . | sort -k2 >/tmp/before
echo "Insure all code is formatted"
go fmt ./...
echo "Insure all code is linted"
golint --set_exit_status=true ./...
echo "Insure all code is vetted"
go vet ./...
echo "Insure all code passes unit tests and coverage is updated appropriately"
go test ./... --cover
md5deep -r . | sort -k2 >/tmp/after
if [[ $# -ne 1 ]] && [[ $1 != "true" ]]; then
# If any changes from format or unit test coverage then fail so people check in the formatted files and updated coverage
echo "If any changes from format or unit test coverage then fail so people check in the formatted files and updated coverage"
diff /tmp/before /tmp/after
fi