1#! /bin/bash
2
3set -eu
4
5# make the GIT_DIR and GIT_INDEX_FILE absolute, before we change dir
6export GIT_DIR=$(readlink -f `git rev-parse --git-dir`)
7if [ -n "${GIT_INDEX_FILE:+x}" ]; then
8    export GIT_INDEX_FILE=$(readlink -f "$GIT_INDEX_FILE")
9fi
10
11wd=`pwd`
12
13# create a temp dir. The `trap` incantation will ensure that it is removed
14# again when this script completes.
15tmpdir=`mktemp -d`
16trap 'rm -rf "$tmpdir"' EXIT
17cd "$tmpdir"
18
19# get a clean copy of the index (ie, what has been `git add`ed), so that we can
20# run the checks against what we are about to commit, rather than what is in
21# the working copy.
22git checkout-index -a
23
24echo "Installing lint search engine..."
25curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
26
27echo "Testing..."
28go test ./...
29
30echo "Looking for lint..."
31golangci-lint run
32
33echo "Double checking spelling..."
34misspell -error src *.md
35
36echo "Done!"
37