Created
August 3, 2016 21:05
-
-
Save atelic/86dac06e0d77de8197fe24a002385dd3 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/env bash | |
RUN_TEST_COMMAND="" | |
find . -name "*.pyc" -delete | |
git diff --cached --name-only | while read FILE; do | |
if [[ "$FILE" =~ ^.+(py)$ ]]; then | |
if [[ -f $FILE ]]; then | |
python -m py_compile "$FILE" 1> /dev/null | |
if [ $? -ne 0 ]; then | |
echo -e "\e[1;31mAborting commit due to files with syntax errors.\e[0m" >&2 | |
exit 1 | |
fi | |
RESULT=$(grep "ipdb.set" "$FILE") | |
if [ ! -z $RESULT ]; then | |
echo -e "\e[1;33mWarning, the commit contains a call to ipdb. Commit was not aborted, however.\e[0m" >&2 | |
fi | |
fi | |
elif [[ "$FILE" =~ ^.+(js|jsx|html)$ ]]; then | |
if [[ -f "$FILE" ]]; then | |
RESULT=$(grep "debugger" "$FILE") | |
if [ ! -z $RESULT ]; then | |
echo -e "\e[1;33mAborting commit due to call to debuger;.\e[0m" >&2 | |
exit 1 | |
fi | |
fi | |
fi | |
done || exit $? | |
if [ $? -eq 0 ]; then | |
"$RUN_TEST_COMMAND" | |
if [ $? -ne 0 ]; then | |
echo -e "\e[1;31m\tUnit tests failed ! Aborting commit.\e[0m" >&2 | |
exit 1; | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment