Tweak pre-commit to ignore vendor directory.
This commit is contained in:
parent
bcbe5fae3f
commit
4b7a63c631
|
@ -1,5 +1,13 @@
|
||||||
#!/bin/bash
|
#!/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
|
if [ -n "$failIt" ]; then
|
||||||
echo "Expecting failIt to be empty."
|
echo "Expecting failIt to be empty."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -7,25 +15,25 @@ fi
|
||||||
|
|
||||||
wantEmpty=$(gofmt -s -d -l . 2>&1 )
|
wantEmpty=$(gofmt -s -d -l . 2>&1 )
|
||||||
if [ -n "$wantEmpty" ]; then
|
if [ -n "$wantEmpty" ]; then
|
||||||
printf >&2 'gofmt failed for:\n%s\n' "$wantEmpty"
|
printf >&2 '\ngofmt failed for:\n%s\n' "$wantEmpty"
|
||||||
failIt=1
|
failIt=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wantEmpty=$(goimports -l .)
|
wantEmpty=$(goimports -l $(find . -type f -name '*.go' -not -path "./vendor/*") 2>&1)
|
||||||
if [ -n "$wantEmpty" ]; then
|
if [ -n "$wantEmpty" ]; then
|
||||||
printf >&2 'goimports failed for:\n%s\n' "$wantEmpty"
|
printf >&2 '\ngoimports failed for:\n%s\n' "$wantEmpty"
|
||||||
failIt=1
|
failIt=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wantEmpty=$(go vet -all ./... 2>&1)
|
wantEmpty=$(go vet -all ./... 2>&1)
|
||||||
if [ -n "$wantEmpty" ]; then
|
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
|
failIt=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wantEmpty=$(golint ./...)
|
wantEmpty=$(golint ./...)
|
||||||
if [ -n "$wantEmpty" ]; then
|
if [ -n "$wantEmpty" ]; then
|
||||||
printf >&2 'golint failed for:\n%s\n' "$wantEmpty"
|
printf >&2 '\ngolint failed for:\n%s\n' "$wantEmpty"
|
||||||
failIt=1
|
failIt=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -35,3 +43,4 @@ if [ -n "$failIt" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
Loading…
Reference in New Issue