Simplify pre-commit.

pull/9/head
Joshua Potter 2023-12-03 11:30:14 -07:00
parent 9b9e561e49
commit b4e42e6de2
1 changed files with 5 additions and 6 deletions

View File

@ -1,13 +1,12 @@
#!/usr/bin/env bash
set -e
filesToFormat=$(
FORMAT_FILES=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.py$/ {print $NF}'
)
for path in $filesToFormat
do
black --quiet "$path"
git add "$path"
done;
if [ -n "$FORMAT_FILES" ]; then
black --quiet "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi