From e9cd3319cf14b3d9484c4e6d7aa5040509a81653 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 7 Jan 2020 20:46:18 +0000 Subject: Enable pre-commit tool linting This should help use keep the codebase more consistent, and avoid sevel whitespace related issues, or bad file permissions. pre-commit allows us to easily introduce other linters in follow-ups, like bashate. Note: pre-commit tool does *not* install any git-hooks. Making commits will will call the tool unless you deliverately tell it to install the hooks. Signed-off-by: Sorin Sbarnea --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5d3405387..a018e05b4 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,10 @@ BUILDTAGS ?= \ exclude_graphdriver_devicemapper \ seccomp \ varlink -PYTHON ?= $(shell command -v python python3|head -n1) +PYTHON ?= $(shell command -v python3 python|head -n1) PKG_MANAGER ?= $(shell command -v dnf yum|head -n1) +# ~/.local/bin is not in PATH on all systems +PRE_COMMIT = $(shell command -v bin/venv/bin/pre-commit ~/.local/bin/pre-commit pre-commit | head -n1) SOURCES = $(shell find . -name "*.go") @@ -149,6 +151,11 @@ endif touch $@ lint: golangci-lint +ifeq ($(PRE_COMMIT),) + @echo "FATAL: pre-commit was not found, check https://pre-commit.com/ about installing it." >&2 + @exit 2 +endif + $(PRE_COMMIT) run -a golangci-lint: .gopathok varlink_generate .install.golangci-lint $(GOBIN)/golangci-lint run --tests=false --skip-files swagger.go -- cgit v1.2.3-54-g00ecf