Last active
December 11, 2018 15:46
-
-
Save marcoala/09b958b6c695dbd06ccebd7484297c7c to your computer and use it in GitHub Desktop.
Precommit hook for a python project
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 | |
# colors for pretty output | |
RED="\033[00;31m" | |
BLUE="\033[00;34m" | |
GREEN="\033[00;32m" | |
RESET=$(tput sgr0) | |
echo "Linting python files with flake8" | |
LINTER="$(git diff --name-only --cached | grep .py | xargs python3 -m flake8 --config /Users/marco/Code/development/festicket/setup.cfg {})" | |
if [ -z "$LINTER" ] | |
then | |
echo "🎉 ${GREEN}Flake8 executed without any error!${RESET}" | |
exit 0 | |
else | |
echo "⛔️ ${RED}Flake8 has found some errors, please fix them and then try to commit again${RESET}" | |
echo "${LINTER}" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment