cd .git/hooks
touch pre-push
code pre-push
#!/bin/bash
BRANCH=`git rev-parse --abbrev-ref HEAD`
PUSH_COMMAND=`ps -ocommand= -p $PPID`
DEV_BRANCHES="(dev|stg)"
PROTECTED_BRANCHES="^(master|dev|stg|release-*|patch-*)"
FORCE_PUSH="force|delete|-f"
LAST_COMMIT_MSG_WIP=`git log --pretty=format:"%s" -n 1 | grep -i 'WIP'`
if [[ "$BRANCH" =~ $DEV_BRANCHES ]]; then
echo "do nothing for environment branches"
elif [[ LAST_COMMIT_MSG_WIP ]]; then
echo "do nothing for WIP pushes"
else
bundle exec rubocop --fail-level=autocorrect
bundle exec rspec
fichmod +x .git/hooks/pre-push