Skip to content

Instantly share code, notes, and snippets.

@ssaunier
Last active June 9, 2018 02:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ssaunier/8704755 to your computer and use it in GitHub Desktop.
Save ssaunier/8704755 to your computer and use it in GitHub Desktop.
Hook to rub rspec and karma before each `git push`. Can be bypassed with `git push --no-verify`
cd /path/to/your/repo
curl https://gist.github.com/ssaunier/8704755/raw/pre-push.sh > .git/hooks/pre-push
chmod u+x .git/hooks/pre-push
echo "Running RSpec"
bundle exec rspec spec
spec=$?
echo "Running Karma"
bundle exec rake karma:run
karma=$?
if [ $spec -eq 0 ] && [ $karma -eq 0 ]; then
echo "\\033[32mTests are green, pushing...\\033[0;39m"
exit 0
else
echo "\\033[1;31mCannot push, tests are failing. Use --no-verify to force push.\\033[0;39m"
exit 1
fi
@ssaunier
Copy link
Author

@galiminus
Copy link

Le lien du gist à changer : https://gist.githubusercontent.com/ssaunier/8704755/raw/e65156d080fb1ad8d40feca305bc95baaf165ec8/pre-push.sh

Ou alors faut faire suivre la redirection à curl avec un -L 🍑

@johnhamelink
Copy link

Made it work a bit better on Linux, and added a crunchbang: https://gist.github.com/johnhamelink/577b8613ae82d2b3037b

I wonder: is there a way to have the hook installed automatically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment