diff --git a/bin/pre-commit.sh b/bin/pre-commit.sh index 8e3e11cd..9fd673c7 100755 --- a/bin/pre-commit.sh +++ b/bin/pre-commit.sh @@ -1,5 +1,13 @@ #!/bin/bash +# Runs pre-commit tests. +# +# Instead of failing on first error, complete all checks, then fail if need be. +# Echo go's version to verify against go's behavior below. +# Different versions do different things with respect to vendored code. +go version + +# Assert state. if [ -n "$failIt" ]; then echo "Expecting failIt to be empty." exit 1 @@ -7,25 +15,25 @@ fi wantEmpty=$(gofmt -s -d -l . 2>&1 ) if [ -n "$wantEmpty" ]; then - printf >&2 'gofmt failed for:\n%s\n' "$wantEmpty" + printf >&2 '\ngofmt failed for:\n%s\n' "$wantEmpty" failIt=1 fi -wantEmpty=$(goimports -l .) +wantEmpty=$(goimports -l $(find . -type f -name '*.go' -not -path "./vendor/*") 2>&1) if [ -n "$wantEmpty" ]; then - printf >&2 'goimports failed for:\n%s\n' "$wantEmpty" + printf >&2 '\ngoimports failed for:\n%s\n' "$wantEmpty" failIt=1 fi wantEmpty=$(go vet -all ./... 2>&1) if [ -n "$wantEmpty" ]; then - printf >&2 'govet failed for:\n%s\n' "$wantEmpty" + printf >&2 '\ngo vet failed for:\n%s\n' "$wantEmpty" failIt=1 fi wantEmpty=$(golint ./...) if [ -n "$wantEmpty" ]; then - printf >&2 'golint failed for:\n%s\n' "$wantEmpty" + printf >&2 '\ngolint failed for:\n%s\n' "$wantEmpty" failIt=1 fi @@ -35,3 +43,4 @@ if [ -n "$failIt" ]; then fi go test -v ./... + diff --git a/pkg/kinflate/util.go b/pkg/kinflate/util.go index 799a5516..fe3a4e53 100644 --- a/pkg/kinflate/util.go +++ b/pkg/kinflate/util.go @@ -21,7 +21,7 @@ import ( "io/ioutil" "path" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime"