Skip to content

Instantly share code, notes, and snippets.

@Suor
Last active October 19, 2017 21:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suor/ccac0511e2e9c5a2d282d47f2c6850a0 to your computer and use it in GitHub Desktop.
Save Suor/ccac0511e2e9c5a2d282d47f2c6850a0 to your computer and use it in GitHub Desktop.
Flake8 git pre-commit hook that works
#!/bin/sh
FILES=`git diff --cached --name-status | awk '$1 != "D" {print $2}' | grep -E '[.]py$' | grep -v migrations`
[ "$NOCHECK" != "" ] || [ "$FILES" = "" ] || flake8 $FILES || exit 1
@Suor
Copy link
Author

Suor commented Nov 3, 2016

Flake8 has its own pre-commit hook, but it:

  • ignores config,
  • replaces file paths to /tmp/random_stuff/...,
  • doesn't prevent commiting on error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment