hooks/pre-commit: ignore deleted files

This commit is contained in:
Kevin Baensch 2025-07-10 22:09:16 +02:00
parent 50e72a82e9
commit 065770213d
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -11,7 +11,7 @@ ARCH="$(uname -m)-$(uname | tr "[:upper:]" "[:lower:]")"
NIX_FMT="$(nix build --no-link --print-out-paths .#formatter."${ARCH}")"
RESULT=0;
for file in $(git diff --name-only --cached); do
for file in $(git diff --diff-filter=d --name-only --cached); do
if grep -q "\.nix$" <<< "${file}"; then
"${NIX_FMT}"/bin/nixfmt -c <<< "$(git cat-file blob :"${file}")" 2> >(sed "s|<stdin>|${file}|");
RESULT=$(( RESULT || $? ));