Skip to content

Instantly share code, notes, and snippets.

@tonidezman
Last active August 29, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonidezman/a274316d389b84729508892da48c94d1 to your computer and use it in GitHub Desktop.
Save tonidezman/a274316d389b84729508892da48c94d1 to your computer and use it in GitHub Desktop.
git pre-push hook
# 1) cd /path/to/your/repo
# 2) touch .git/hooks/pre-push
# 3) chmod u+x .git/hooks/pre-push
# 4) add code below to the pre-push file
#!/usr/bin/env bash
echo "Running RSpec"
bundle exec rspec spec
exit_status=$?
if [ $exit_status -eq 0 ]
then
echo -en "\\033[32mTests are green, pushing...\\033[0;39m\n"
exit 0
else
echo -en "\\033[1;31mCannot push, tests are failing. Use --no-verify to force push.\\033[0;39m\n"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment