From ee67dc1f2ee9b6cfe4d345ea0620c8f9ae5d0cc1 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 18 Jun 2019 14:32:47 +0100 Subject: [PATCH 1/3] pre-commit hook: avoid avoid setting GIT_DIR when running go It seems that `go get` explodes and craps over your git directory if you set GIT_DIR, and some of the go tools run `go get` indirectly, so let's jump through some hoops to fix it. --- hooks/pre-commit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 736f559..ec3374e 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -2,8 +2,12 @@ set -eu -# make the GIT_DIR and GIT_INDEX_FILE absolute, before we change dir -export GIT_DIR=$(readlink -f `git rev-parse --git-dir`) +# make git_dir and GIT_INDEX_FILE absolute, before we change dir +# +# (don't actually set GIT_DIR, because it messes up `go get`, and several of +# the go commands run `go get` indirectly) +# +git_dir=$(readlink -f `git rev-parse --git-dir`) if [ -n "${GIT_INDEX_FILE:+x}" ]; then export GIT_INDEX_FILE=$(readlink -f "$GIT_INDEX_FILE") fi @@ -19,7 +23,7 @@ cd "$tmpdir" # get a clean copy of the index (ie, what has been `git add`ed), so that we can # run the checks against what we are about to commit, rather than what is in # the working copy. -git checkout-index -a +git --git-dir="${git_dir}" checkout-index -a # run our checks golint src/... @@ -28,6 +32,9 @@ go tool vet --shadow ./src gocyclo -over 12 src/ gb test +# we're done with go so can set GIT_DIR +export GIT_DIR="$git_dir" + # if there are no changes from the index, we are done git diff --quiet && exit 0 From 45cceda6d428a727b17004f5fab1811e0342ee51 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 18 Jun 2019 11:13:36 +0100 Subject: [PATCH 2/3] fix name of golint apparently this is the right module name for golint :shrug: --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3549fac..431fe92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,6 @@ go: - "1.11" install: - go get github.com/constabulary/gb/... - - go get github.com/golang/lint/golint + - go get golang.org/x/lint/golint - go get github.com/fzipp/gocyclo script: ./hooks/pre-commit From 50df916f097d1951790db66afe298c6ef336192f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 18 Jun 2019 10:54:40 +0100 Subject: [PATCH 3/3] Remove support for < 1.11 go modules require 1.11. --- .travis.yml | 4 +--- README.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 431fe92..54c6ac8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: go go: - - "1.9" - - "1.10" - - "1.11" + - "1.11" install: - go get github.com/constabulary/gb/... - go get golang.org/x/lint/golint diff --git a/README.md b/README.md index f26a52c..63808a2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Web service which collects and serves bug reports. -rageshake requires Go version 1.9 or later. +rageshake requires Go version 1.11 or later. To run it, do: