Created
September 14, 2016 09:15
-
-
Save atarkowska/c51f94f5aa9c6d4463a490cecd524ef8 to your computer and use it in GitHub Desktop.
pre-commit hooks
This file contains hidden or 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 | |
# automatically configured by git-annex | |
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.py$') | |
if [ -n "$FILES" ]; then | |
if output=$(flake8 $FILES) && [ -z "$output" ]; then | |
echo 'Flake8 pass. Ready to commit.' | |
else | |
echo 'Flake8 errors.' | |
echo "$output" | |
exit 1 | |
fi | |
fi | |
if [ -n "$FILES" ]; then | |
if output=$(pylint --disable all --enable spelling --spelling-dict en_US $FILES) && [ -z "$output" ]; then | |
echo 'Spelling ok' | |
else | |
echo 'Spelling errors.' | |
echo "$output" | |
# Allows us to read user input below, assigns stdin to keyboard | |
exec < /dev/tty | |
while true; do | |
read -p "Would you like to commit? (Y/n) " yn | |
if [ "$yn" = "" ]; then | |
yn='Y' | |
fi | |
case $yn in | |
[Yy] ) bundle outdated --pre; break;; | |
[Nn] ) exit 1;; | |
* ) echo "Please answer y or n for yes or no.";; | |
esac | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment