Created
June 9, 2023 11:36
pre-commit hook script for Python projects (personal use)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage: poetry install pre-commit install | |
# File generated by pre-commit: https://pre-commit.com | |
# start templated | |
INSTALL_PYTHON=[Project Path]/.venv/bin/python | |
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit) | |
# end templated | |
HERE="$(cd "$(dirname "$0")" && pwd)" | |
ARGS+=(--hook-dir "$HERE" -- "$@") | |
if [ -x "$INSTALL_PYTHON" ]; then | |
exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" | |
elif command -v pre-commit > /dev/null; then | |
exec pre-commit "${ARGS[@]}" | |
else | |
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment