Skip to content

Instantly share code, notes, and snippets.

@curtischong curtischong/pre-commit
Last active Jun 19, 2019

What would you like to do?
git pre-commit flake8 cancer
# TODO: Place in .git/hooks/
# TODO: Run chmod +x pre-commit
changed-files () {
git diff-tree --no-commit-id --name-only -r ${@:-HEAD}
exists () {
while read line; do
test -f $line && echo $line
root=$(git rev-parse --show-toplevel)
cd $root
# To check the flake8 for the file's imports use: --builtins=func_name
files=$(changed-files $@ | grep '\.py$' | exists)
test -z "$files" || flake8 --ignore=W292,E501,E265,F404,E302,E305 $files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.