File: pre-commit

package info (click to toggle)
golang-github-puerkitobio-goquery 1.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 880 kB
  • sloc: sh: 27; makefile: 3
file content (37 lines) | stat: -rwxr-xr-x 815 bytes parent folder | download
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
#!/bin/sh

echo ">>> golint"
for dir in $(go list ./... | grep -v /vendor/)
do
    golint "${dir}"
done
echo "<<< golint"
echo

echo ">>> go vet"
go vet $(go list ./... | grep -v /vendor/)
echo "<<< go vet"
echo

echo ">>> gosimple"
gosimple $(go list ./... | grep -v /vendor/)
echo "<<< gosimple"
echo

# Check for gofmt problems and report if any.
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$' | grep -v /vendor/)
[ -z "$gofiles" ] && echo "EXIT $vetres" && exit $vetres

if [ -n "$gofiles" ]; then
    unformatted=$(gofmt -l $gofiles)

    if [ -n "$unformatted" ]; then
        # Some files are not gofmt'd.
        echo >&2 "Go files must be formatted with gofmt. Please run:"
        for fn in $unformatted; do
            echo >&2 "  gofmt -w $PWD/$fn"
        done
    fi
fi
echo