From e6c3b0cf3e91b01c7f3eb8ce5a21155142d4dd15 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Sun, 10 Dec 2023 13:52:38 -0500 Subject: [PATCH] Ignore deleted files in git hook --- hooks/pre-commit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 340e822f..74348b17 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -11,7 +11,8 @@ else against=$(git hash-object -t tree /dev/null) fi # cat always has error code 0 -filenames=$(git diff --cached --name-only $against | grep '\.py$' | cat) +# ignore deleted files (can't be formatted) +filenames=$(git diff --cached --name-only --diff-filter=d $against | grep '\.py$' | cat) if [ -n "$filenames" ] then ./scrapscript.py test