File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,31 +28,17 @@ documentation-ci: deps documentation
2828lint :
2929 stylua .
3030
31- # installs the repo pre-commit hook that runs `make precommit` before every commit .
32- precommit -install :
33- @mkdir -p .git/hooks
34- @printf ' #!/usr/bin/env bash\nmake precommit\n ' > .git/hooks/pre-commit
35- @chmod +x .git/hooks/pre-commit
36- @echo " pre-commit hook installed at .git/hooks/pre-commit "
37-
38- # runs the pre-commit checks: lints all Lua files (auto-fixing anything that
39- # isn't formatted), regenerates docs, and re-stages any files that changed .
31+ # installs the lefthook-managed git hooks defined in `lefthook.yml` .
32+ hooks -install :
33+ @command -v lefthook > /dev/null 2>&1 || { \
34+ echo " hooks-install: lefthook is not installed (brew install lefthook) " >&2 ; \
35+ exit 1 ; \
36+ }
37+ @lefthook install
38+
39+ # runs the lefthook pre-commit jobs on demand, outside of git .
4040precommit :
41- @set -eu; \
42- if command -v stylua > /dev/null 2>&1 ; then \
43- stylua . ; \
44- reformatted=$$(git diff --name-only -- '*.lua' ) ; \
45- if [ -n " $$ reformatted" ]; then \
46- echo " precommit: re-staging stylua-formatted files:" ; \
47- echo " $$ reformatted" | sed ' s/^/ /' ; \
48- git add $$ reformatted; \
49- fi ; \
50- stylua --check . ; \
51- else \
52- echo " precommit: stylua not installed; skipping lint" >&2 ; \
53- fi ; \
54- $(MAKE ) documentation; \
55- git add doc
41+ @lefthook run pre-commit
5642
5743clean :
5844 rm -rf deps
Original file line number Diff line number Diff line change 1+ pre-commit :
2+ parallel : false
3+ jobs :
4+ - name : stylua
5+ glob : " *.lua"
6+ run : stylua {staged_files}
7+ stage_fixed : true
8+ - name : documentation
9+ glob : " *.lua"
10+ run : make documentation
11+ stage_fixed : true
You can’t perform that action at this time.
0 commit comments