coach-scraper/.githooks/pre-commit

13 lines
248 B
Plaintext
Raw Normal View History

2023-11-27 20:09:40 +00:00
#!/usr/bin/env bash
set -e
2023-12-03 18:30:14 +00:00
FORMAT_FILES=$(
2023-11-27 20:09:40 +00:00
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.py$/ {print $NF}'
)
2023-12-03 18:30:14 +00:00
if [ -n "$FORMAT_FILES" ]; then
black --quiet "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi