Skip to content

Commit

Permalink
Ignore deleted files in git hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed Dec 10, 2023
1 parent 46fbbb4 commit e6c3b0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e6c3b0c

Please sign in to comment.