forked from getlantern/lantern
-
Notifications
You must be signed in to change notification settings - Fork 12
/
prehook.sh
executable file
·59 lines (50 loc) · 1.95 KB
/
prehook.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# Shared pre push/commit hook for the Lantern project
# Maintainer: Ulysses Aalto <[email protected]>
#
# Installation: Symlink or copy into .git/hooks/prehook.sh
echo "Running hook -- Analyzing modified packages..."
FOUND_CHANGE=false
for i in $MODIFIED_DIRS; do
echo " * $i";
FOUND_CHANGE=true;
done
if [ "$FOUND_CHANGE" = false ]; then
echo "No changes to analyze";
exit 0;
fi
cd src/github.com/getlantern
which errcheck >/dev/null || (echo "Unable to find errcheck, please install it: \`go get github.com/kisielk/errcheck\`" && exit 1)
which golint >/dev/null || (echo "Unable to find golint, please install it: \`go get -u github.com/golang/lint/golint\`" && exit 1)
echo "*** Running \033[0;34mErrcheck\033[0m ***" && \
for dir in $MODIFIED_DIRS; do
errcheck github.com/getlantern/$dir || (\
echo "\033[0;31merrcheck returned error analyzing the package '$dir'\033[0m" && \
echo "Please, fix and run again\n" && \
exit 1)
done
echo "\033[1;34mErrcheck\033[0m ran successfully\n"
echo "*** Running \033[0;34mGo vet\033[0m ***" && \
for dir in $MODIFIED_DIRS; do
go vet github.com/getlantern/$dir || (\
echo "\033[0;31mgo vet returned error analyzing the package '$dir'\033[0m"
echo "Please, fix and run again\n" && \
exit 1)
done
echo "\033[1;34mGo vet\033[0m ran successfully\n"
echo "*** Running \033[0;34mGolint\033[0m ***" && \
for dir in $MODIFIED_DIRS; do
golint github.com/getlantern/$dir || (\
echo "\033[0;31mgo vet returned error analyzing the package '$dir'\033[0m"
echo "Please, fix and run again\n" && \
exit 1)
done
echo "\033[1;34mGolint\033[0m ran successfully\n"
echo "*** Running \033[0;34mGo test -race\033[0m ***" && \
for dir in $MODIFIED_DIRS; do
go test -race github.com/getlantern/$dir || (\
echo "\033[0;31mgo vet returned error analyzing the package '$dir'\033[0m"
echo "Please, fix and run again\n" && \
exit 1)
done
echo "\033[1;34mGo test -race\033[0m ran successfully\n"