searxng/.githooks/pre-commit
Grant Lanham bce9669d74 Create a pre-commit hook which is copied on installation
Allow propogating specific files to format for black

Update build messages for black

update hook

Update hook further, add related doc
2024-08-26 22:00:59 -04:00

12 lines
503 B
Bash
Executable file

#!/bin/sh
if [ "$SEARXNG_PRECOMMIT" = "true" ]; then
# inspired from: https://prettier.io/docs/en/precommit.html#option-4-shell-script
staged_files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
python_files=$(echo "$staged_files" | grep '\.py$')
# Only attempt to run the formatter if Python files were changes
if [ -n "$python_files" ]; then
echo "$python_files" | xargs ./manage format.python
echo "$python_files" | xargs git add
fi
fi