From cb8aad8fba664588d61a2b671fbe1552964908c8 Mon Sep 17 00:00:00 2001 From: Antoni Duda Date: Sat, 5 Oct 2024 00:53:21 +0200 Subject: [PATCH] pre-commit: Add hook for yapf-diff --- .pre-commit-hooks.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3eba1f2e7..e834fc4db 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -7,3 +7,15 @@ args: [-i] #inplace language: python types: [python] + +- id: yapf-diff + name: yapf-diff + description: "A formatter for Python files. (formats only changes included in commit)" + always_run: true + language: python + pass_filenames: false + stages: [pre-commit] + entry: | + bash -c "git diff -U0 --no-color --relative HEAD \ + | yapf-diff \ + | tee >(git apply --allow-empty -p0)"