diff --git a/Makefile b/Makefile index 3d6dd395a..b22d04716 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL := help -.PHONY: help bootstrap lint lint-all check fmt \ +.PHONY: help bootstrap ensure-hooks lint lint-all check fmt \ mindmap go-build go-test go-lint go-fmt go-vet go-tidy \ lint-md-links script-test test \ e2e-test behaviour-test lint-eval-cases functional-tests @@ -71,10 +71,19 @@ bootstrap: @echo "==> Bootstrap complete!" @echo " Make sure $(BOOTSTRAP_BIN_DIR) is on your PATH." -lint: +ensure-hooks: + @if [ -z "$$CI" ] && [ -z "$$(git config --get core.hooksPath 2>/dev/null)" ]; then \ + hooks_dir=$$(git rev-parse --git-path hooks 2>/dev/null); \ + if [ -n "$$hooks_dir" ] && [ ! -f "$$hooks_dir/pre-commit" ]; then \ + echo "==> Installing pre-commit hooks..."; \ + pre-commit install; \ + fi; \ + fi + +lint: ensure-hooks pre-commit run -lint-all: +lint-all: ensure-hooks pre-commit run --all-files check: