feat: add git hook (lefthook)

And remove Makefile
This commit is contained in:
Yorick Barbanneau 2024-05-25 01:25:42 +02:00
parent 9696ec6889
commit c666484b22
2 changed files with 26 additions and 48 deletions

View file

@ -1,48 +0,0 @@
-include include.mk
# pelican variables
P_OUTPUT?=output
P_OPT?=
# deploy variables
D_BIN?=rsync
D_OPT?=-avz --delete
D_DST?="blog:$(D_FOLDER)"
# venv variables
VENV_SOURCE?=.venv
REQUIREMENT?=requirements.txt
PYTHON_BIN?=python3
VENV_CMD?=. $(VENV_SOURCE)/bin/activate
# Pelican part
.PHONY: build
build: $(VENV_SOURCE)/dep
$(VENV_CMD) && pelican -o $(P_OUTPUT) $(P_OPT)
.PHONY: deploy
deploy: build
[ -d $(P_OUTPUT) ] && $(D_BIN) $(D_OPT) $(P_OUTPUT)/ $(D_DST)
.PHONY: clean
clean:
[ -d $(P_OUTPUT) ] && rm -rf $(P_OUTPUT)
# venv management
$(VENV_SOURCE):
$(PYTHON_BIN) -m venv $(VENV_SOURCE)
$(REQUIREMENT):
$(VENV_SOURCE)/dep: $(VENV_SOURCE) $(REQUIREMENT)
touch $(VENV_SOURCE)/dep
$(VENV_CMD) && pip install -r $(REQUIREMENT)
.PHONY: clean-venv
clean-venv:
[ -d $(VENV_SOURCE) ] && rm -rf $(VENV_SOURCE)
.PHONY: serve
serve: $(VENV_SOURCE)/dep
$(VENV_CMD) && invoke livereload

26
lefthook.yaml Normal file
View file

@ -0,0 +1,26 @@
---
commit-msg:
parallel: true
commands:
lint:convco:
run: cat {1} | convco check --from-stdin
lint:typos:
run: cat {1} | typos -
pre-commit:
parallel: true
commands:
nixcheck:
glob: "flake.{nix,lock}"
run: nix flake check
shellcheck:
glob: "*.sh"
run: shellcheck {staged_files}
shfmt:
glob: "*.sh"
run: shfmt -d -ln bash -i 4 {staged_files}