Created
February 22, 2020 20:46
-
-
Save goncalor/1f5e1dc7375cc547a29b86b40d9449e6 to your computer and use it in GitHub Desktop.
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 | |
# | |
# A hook script to verify what is about to be committed. | |
# Called by "git commit" with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.py$") | |
pass=true | |
for file in ${files}; do | |
yapf -d ${file} | |
if [ $? -eq 0 ]; then | |
echo -e "\e[1;32mPassed:\e[0m ${file}" | |
else | |
echo -e "\e[1;31mFailed:\e[0m ${file}" | |
pass=false | |
fi | |
done | |
if ! $pass; then | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment