Last active
December 19, 2015 06:29
-
-
Save edgar/5912135 to your computer and use it in GitHub Desktop.
Git: Post-merge git hook that detects changes on Gemfile and migrations folder, to notify that you should run `bundle install` or `rake db:migrate` #git #hook #post-merge
This file contains hidden or 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
# This script detects changes on Gemfile and migrations folder | |
# Instructions: | |
# Put this file into your .git/hooks folder and set as executable (chmod +x post-merge) | |
#--------------------------------------------- | |
#!/bin/sh | |
diff=`git diff --name-only HEAD@{1} HEAD` | |
migrate=`expr "$diff" : ".*db/migrate.*"` | |
bundle=`expr "$diff" : ".*Gemfile*"` | |
if [ ! "$bundle" -eq 0 ] | |
then | |
title='Bundle needed!' | |
message="You should run 'bundle install'" | |
appname="Git merge" | |
command -v notify-send >/dev/null 2>&1 && notify-send --icon=info "$title" "$message" | |
command -v growlnotify >/dev/null 2>&1 && growlnotify -n "$appname" -m "$message" -t "$title" | |
echo "" | |
echo "###################################" | |
echo "# Changes in Gemfile detected! #" | |
echo "# You should run 'bundle install' #" | |
echo "###################################" | |
echo "" | |
fi | |
if [ ! "$migrate" -eq 0 ] | |
then | |
title='Migration needed!' | |
message="You should run 'rake db:migrate'" | |
appname="Git merge" | |
command -v notify-send >/dev/null 2>&1 && notify-send --icon=info "$title" "$message" | |
command -v growlnotify >/dev/null 2>&1 && growlnotify -n "$appname" -m "$message" -t "$title" | |
echo "" | |
echo "####################################" | |
echo "# Migration file detected! #" | |
echo "# You should run 'rake db:migrate' #" | |
echo "####################################" | |
echo "" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment