Skip to content

Instantly share code, notes, and snippets.

@guyguyon
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save guyguyon/4403035fe92cd1260ef8 to your computer and use it in GitHub Desktop.

Select an option

Save guyguyon/4403035fe92cd1260ef8 to your computer and use it in GitHub Desktop.
#!/bin/sh
branch=`git rev-parse --abbrev-ref HEAD`
echo "Running tests before pushing...."
if [[ $branch == 'master' || $branch == 'develop' ]];
then
# SET IT TO YOUR OWN VIRTUALENV PATH !
source ~/virtualenv/mp_api/bin/activate
root_path=`git rev-parse --show-toplevel`
cd $root_path"/mp_api"
./manage.py test
exit_code=$?
cd -
if [ $exit_code -gt 0 ]
then echo "Did not push because of failing tests"
else echo "Tests were passed successfully"
fi
exit $exit_code
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment