forked from wowsims/tbc-new
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
31 lines (29 loc) · 675 Bytes
/
Copy pathpre-commit
File metadata and controls
31 lines (29 loc) · 675 Bytes
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
#!/bin/sh
# NOTE: This script does not play well when adding partial changes, such as with
# git add -p or git commit -p.
test_fmt() {
hash gofmt 2>&- || { echo >&2 "gofmt not in PATH."; exit 1; }
IFS='
'
exitcode=0
for file in `git diff --cached --name-only --diff-filter=ACM | grep '\.go$'`
do
output=`gofmt -w "$file"`
if test -n "$output"
then
# any output is a syntax error
echo >&2 "$output"
exitcode=1
fi
git add "$file"
done
exit $exitcode
}
case "$1" in
--about )
echo "Check Go code formatting"
;;
* )
test_fmt
;;
esac