Created
January 13, 2021 22:23
-
-
Save lutostag/df496e09dcf135c3fac55da83bb97476 to your computer and use it in GitHub Desktop.
python basci pre-commit
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
#!/bin/sh | |
# | |
# To enable this hook, rename this file to "pre-commit". | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=$(git hash-object -t tree /dev/null) | |
fi | |
py_files_changed=$(git diff --cached --name-only $against | grep '.py$') | |
echo $py_files_changed | xargs black | |
echo $py_files_changed | xargs mypy | |
echo $py_files_changed | xargs git add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment