Skip to content

Instantly share code, notes, and snippets.

Last active Dec 18, 2015
What would you like to do?
# This pre-push hook will run 'rake' command to check if your test
# suite passes by looking for ', 0 failures' in the 'rake' output
# If found, will return exit and the git push command will continue
# Make sure you remove the .sh extension and put the hook into your
# .git/hooks directory in your project
# --------------------------------------------------------------------
SUCESS_OUTPUT="\, 0 failures"
echo "This script will run 'rake' command to make sure your test suite passes before pushing"
echo "You can skip this script by adding '--no-verify' to your regular 'git push [repository] [branch]' command"
echo 'This can take a while...'
exec 5>&1
OUTPUT=$( rake |tee /dev/fd/5)
if echo "$OUTPUT" | grep -q "$SUCESS_OUTPUT"; then
echo 'Test passed! proceeding with the push'
echo "Some test did not pass! Failed test are shown above. Push aborted!"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment