From 64bb99aa64db51182ef691d8288e5b267e1b1f31 Mon Sep 17 00:00:00 2001 From: Petru Paler Date: Thu, 1 Jan 2026 07:50:57 +0000 Subject: [PATCH] chore: migrate to lefthook for git hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom bash pre-commit hook with lefthook for: - Parallel execution of ruff + pytest - Quieter output (pytest -q instead of -v) - Version-controlled config (lefthook.yml) - Smart skipping when no .py files staged 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 1 + flake.nix | 1 + lefthook.yml | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 lefthook.yml diff --git a/.gitignore b/.gitignore index 76d5515..11d7a36 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ build/ .env *.local .sesskey +lefthook-local.yml diff --git a/flake.nix b/flake.nix index 1ae01f7..61057ac 100644 --- a/flake.nix +++ b/flake.nix @@ -78,6 +78,7 @@ pkgs.jq pkgs.sqlite pkgs.skopeo # For pushing Docker images + pkgs.lefthook # Git hooks manager ]; shellHook = '' diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..d581ee8 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,15 @@ +# ABOUTME: Git hooks configuration using lefthook. +# ABOUTME: Runs ruff linting/formatting and pytest before commits. + +pre-commit: + parallel: true + commands: + ruff-check: + glob: "**/*.py" + run: ruff check src/ tests/ + ruff-format: + glob: "**/*.py" + run: ruff format --check src/ tests/ + pytest: + glob: "**/*.py" + run: pytest tests/ -q --tb=short