Last active
December 18, 2015 11:19
-
-
Save FerPerales/5774960 to your computer and use it in GitHub Desktop.
pre-push
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
#!/bin/sh | |
# 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 | |
# -------------------------------------------------------------------- | |
#!/bin/sh | |
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' | |
exit | |
else | |
echo "Some test did not pass! Failed test are shown above. Push aborted!" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment