Skip to content

Instantly share code, notes, and snippets.

@lcguida
Forked from calebhaye/pre-push
Last active August 4, 2017 14:21
Show Gist options
  • Save lcguida/9dff5706ef9abc14e6c48b6b6b7b473d to your computer and use it in GitHub Desktop.
Save lcguida/9dff5706ef9abc14e6c48b6b6b7b473d to your computer and use it in GitHub Desktop.
Run tests before git push (within specified branches)
#!/bin/bash
branches_to_test=('master' 'staging' 'develop')
branch=`git rev-parse --abbrev-ref HEAD`
test_branch () {
local e
for e in "${branches_to_test[@]}"
do
[[ "$e" == $1 ]] && return 0
done
return 1
}
if test_branch $branch ; then
echo "Running tests before pushing ...."
exit_code=$(bundle exec rake > /dev/null 2>/dev/null )$?
if [ $exit_code -gt 0 ]
then echo "Did not push because of failing tests"
fi
exit $exit_code
fi
exit 0
@lcguida
Copy link
Author

lcguida commented Aug 4, 2017

Still missing the output of test during push.

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