Skip to content

Instantly share code, notes, and snippets.

@alebian
Last active April 16, 2019 13:25
Show Gist options
  • Save alebian/d7b3e18549599cacec3f16621c67e6f5 to your computer and use it in GitHub Desktop.
Save alebian/d7b3e18549599cacec3f16621c67e6f5 to your computer and use it in GitHub Desktop.
#!/bin/sh
mkdir .githooks
curl https://gist.githubusercontent.com/alebian/d7b3e18549599cacec3f16621c67e6f5/raw/pre-push.sh > .githooks/pre-push
chmod u+x .githooks/pre-push
git config core.hooksPath ./.githooks
#!/bin/sh
curl https://gist.githubusercontent.com/alebian/d7b3e18549599cacec3f16621c67e6f5/raw/pre-push.sh > .git/hooks/pre-push
chmod u+x .git/hooks/pre-push
#!/bin/sh
echo "Running Rubocop"
bundle exec rubocop -R Gemfile app spec
rubocop=$?
if [ $rubocop -eq 0 ]; then
echo "\\033[32mRubocop passed!\\033[0;39m"
else
echo "\\033[1;31mCannot push, some cops are failing. Use --no-verify to force push.\\033[0;39m"
exit 1
fi
echo "Running RSpec"
bundle exec rspec
spec=$?
if [ $spec -eq 0 ]; then
echo "\\033[32mRspec passed!\\033[0;39m"
exit 0
else
echo "\\033[1;31mCannot push, some specs are failing. Use --no-verify to force push.\\033[0;39m"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment