diff --git a/.husky/hooks/pre-commit b/.husky/hooks/pre-commit new file mode 100755 index 00000000..cb57df8b --- /dev/null +++ b/.husky/hooks/pre-commit @@ -0,0 +1,3 @@ +#!/bin/bash + +husky install \ No newline at end of file diff --git a/.husky/hooks/pre-push b/.husky/hooks/pre-push new file mode 100755 index 00000000..66128065 --- /dev/null +++ b/.husky/hooks/pre-push @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +if [[ -n "$(git status --short)" ]]; then + git stash + function unstash() { + git reset --hard + git stash pop + } + trap unstash EXIT +fi + +make manifests generate test + +git diff --exit-code --quiet || (git status && exit 1) diff --git a/Makefile b/Makefile index 1c79f408..87431340 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,10 @@ KUSTOMIZE = $(shell pwd)/bin/kustomize kustomize: ## Download kustomize locally if necessary. $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v$(KUSTOMIZE_VERSION)) +HUSKY = $(shell pwd)/bin/husky +.PHONY: husky +husky: ## Download husky locally if necessary. + $(call go-get-tool,$(HUSKY),github.com/automation-co/husky@v0.2.5) # go-get-tool will 'go get' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))