Skip to content

Instantly share code, notes, and snippets.

@philtr
Created August 20, 2014 20:55
Show Gist options
  • Save philtr/02519c21aec26f2fb4d3 to your computer and use it in GitHub Desktop.
Save philtr/02519c21aec26f2fb4d3 to your computer and use it in GitHub Desktop.
Run tests and prompt before git push if they fail
#!/bin/bash
function run_tests {
bundle exec rspec
}
function double_check {
echo -e "\n"
read -p "WARNING: Your tests failed. Are you sure you want to push? " -n 1 -r < /dev/tty
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
exit 0 # push will execute
fi
exit 1 # push will not execute)
}
run_tests || double_check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment