Skip to content

Instantly share code, notes, and snippets.

@lutostag
Created January 13, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lutostag/df496e09dcf135c3fac55da83bb97476 to your computer and use it in GitHub Desktop.
Save lutostag/df496e09dcf135c3fac55da83bb97476 to your computer and use it in GitHub Desktop.
python basci pre-commit
#!/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