🚀 feat(githooks, Makefile): add pre-commit hook to run 'make format' before committing

🔧 chore(Makefile): add 'init' target to install pre-commit hooks
The pre-commit hook is added to run 'make format' before committing. This ensures that the code is formatted correctly before it is committed. The Makefile is updated to include an 'init' target that installs the pre-commit hooks.
This commit is contained in:
Gabriel Almeida 2023-05-27 12:59:44 -03:00
commit d5f2d83511
2 changed files with 10 additions and 1 deletions

2
.githooks/pre-commit Executable file
View file

@ -0,0 +1,2 @@
make format

View file

@ -1,7 +1,13 @@
.PHONY: all format lint build build_frontend install_frontend run_frontend run_backend dev help tests coverage
.PHONY: all init format lint build build_frontend install_frontend run_frontend run_backend dev help tests coverage
all: help
init:
@echo 'Installing pre-commit hooks'
git config core.hooksPath .githooks
pre-commit install
pre-commit install --hook-type pre-push
coverage:
poetry run pytest --cov \
--cov-config=.coveragerc \
@ -14,6 +20,7 @@ tests:
format:
poetry run black .
poetry run ruff --select I --fix .
cd src/frontend && npm run format
lint:
poetry run mypy .