From 1149e7cdfd9edc69688e53b3ef1e8af05fff11b1 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Thu, 24 Sep 2026 00:29:05 +0000 Subject: [PATCH] Add pre-commit hooks and blame-ignore for the lint/format commit --- .git-blame-ignore-revs | 3 +++ .gitignore | 2 ++ lefthook.yml | 19 +++++++++++++++++++ pyproject.toml | 1 + 4 files changed, 25 insertions(+) create mode 100644 .git-blame-ignore-revs create mode 100644 lefthook.yml diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..6b43096 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +# Mass lint/format commits that add noise to git blame. +# Enable locally with: git config blame.ignoreRevsFile .git-blame-ignore-revs +38f3cce # Apply linters and formatters diff --git a/.gitignore b/.gitignore index 0dfef6f..4862965 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ package-lock.json .* !.gitignore !.gitea/ +!.git-blame-ignore-revs +!.pre-commit-config.yaml diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..d4a42c7 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,19 @@ +pre-commit: + parallel: true + commands: + ruff-check: + glob: "*.py" + run: .venv/bin/ruff check --fix {staged_files} + stage_fixed: true + ruff-format: + glob: "*.py" + run: .venv/bin/ruff format {staged_files} + stage_fixed: true + oxlint: + glob: "frontend/src/**" + run: npm --prefix frontend run lint + stage_fixed: true + oxfmt: + glob: "frontend/src/**" + run: npm --prefix frontend run format + stage_fixed: true diff --git a/pyproject.toml b/pyproject.toml index f4baccd..5382fb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,7 @@ gui = [ [dependency-groups] dev = [ "httpx>=0.28.1", + "lefthook>=2.1.14", "ruff>=0.15.14", "setuptools-scm>=8", ]