File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ BIN := $(notdir $(CURDIR))
22
33all :
44 @if [ ! -f " .git/hooks/pre-commit" ]; then \
5- $(MAKE ) precommit- install; \
5+ $(MAKE ) install-hooks ; \
66 fi
77 $(MAKE ) build
88 $(MAKE ) run
@@ -31,28 +31,6 @@ uninstall:
3131lint :
3232 golangci-lint run ./...
3333
34- .PHONY : precommit-install
35- precommit-install :
36- @echo " Installing pre-commit hooks..."
37- @echo " #!/bin/sh\n\nmake precommit" > .git/hooks/pre-commit
38- @chmod +x .git/hooks/pre-commit
39- @echo " Pre-commit hooks installed."
40-
41- .PHONY : precommit
42- precommit :
43- @STAGED_FILES=$$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.go$$' ) ; \
44- if [ -z " $$ STAGED_FILES" ]; then \
45- echo " No staged Go files to check." ; \
46- else \
47- set -e; \
48- echo " Running pre-commit checks..." ; \
49- echo " go fmt" ; \
50- go fmt ./...; \
51- git add $$ STAGED_FILES; \
52- echo " go vet" ; \
53- go vet ./...; \
54- echo " golangci-lint" ; \
55- golangci-lint run ./...; \
56- echo " go test" ; \
57- go test -v ./...; \
58- fi
34+ .PHONY : install-hooks
35+ install-hooks :
36+ lefthook install
Original file line number Diff line number Diff line change 1+ pre-commit :
2+ parallel : true
3+ commands :
4+ fmt :
5+ glob : " *.go"
6+ run : go fmt ./...
7+ stage_fixed : true
8+ vet :
9+ glob : " *.go"
10+ run : go vet ./...
11+ lint :
12+ glob : " *.go"
13+ run : golangci-lint run ./...
14+ test :
15+ glob : " *.go"
16+ run : go test -v ./...
You can’t perform that action at this time.
0 commit comments