Created
June 4, 2013 14:55
-
-
Save bumi/5706550 to your computer and use it in GitHub Desktop.
post-merge hook to automatically run bundle install and rake db:migrate if needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# INSTALL | |
# | |
# make sure you have installed lolcat and cowsay | |
# brew install cowsay | |
# gem install lolcat | |
# | |
# filename: post-merge | |
# | |
# Install as a global post-merge hook for every NEW git repository | |
# save it as git hook template in your share/git-core/templates/hooks (for example: /usr/local/Cellar/git/1.8.2.2/share/git-core/templates/hooks/) | |
# | |
# Or in your local git repository in $GIT_DIR/hooks/* | |
# | |
# | |
diff=`git diff --name-only HEAD@{2} HEAD` | |
migrate=`expr "$diff" : ".*db/migrate.*"` | |
bundle=`expr "$diff" : ".*Gemfile*"` | |
if [ ! "$bundle" -eq 0 ] | |
then | |
echo "Ui, detected a Gemfile change, let's run bundle install" | |
bundle install | |
fi | |
if [ ! "$migrate" -eq 0 ] | |
then | |
echo "Oh, we need to migrate, let's run rake db:migrate" | |
bundle exec rake db:migrate | |
fi | |
if [ -d "tmp" ] | |
then | |
touch 'tmp/restart.txt' | |
fi | |
echo "" | |
echo "`whoami`, have a great day and happy coding" | cowsay | lolcat | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment