Skip to content

Instantly share code, notes, and snippets.

@goncalor
Created February 22, 2020 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goncalor/1f5e1dc7375cc547a29b86b40d9449e6 to your computer and use it in GitHub Desktop.
Save goncalor/1f5e1dc7375cc547a29b86b40d9449e6 to your computer and use it in GitHub Desktop.
#!/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