Last active
December 11, 2015 22:29
-
-
Save chadbailey59/4670369 to your computer and use it in GitHub Desktop.
save this as `.git/hooks/post-merge` in any of your repos. Then, when you do a `git pull` (or really any merge I think), if any migrations were updated or the Gemfile was edited, you'll get a handy reminder to migrate or bundle install.
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
#!/usr/bin/env ruby | |
# Put me in .git/hooks/post-merge | |
# Then do chmod a+x .git/hooks/post-merge | |
migrations = `git diff --name-only master master@{1} | grep db/migrate | wc -l`.strip.to_i | |
if migrations > 0 | |
puts " " | |
puts "**************************************************************" | |
puts "**************************************************************" | |
if migrations > 1 | |
puts "You just pulled changes that included #{migrations} database migrations." | |
else | |
puts "You just pulled changes that included a database migration." | |
end | |
puts "You should run `rake db:migrate` and `rake db:test:prepare`." | |
puts " " | |
end | |
gems = `git diff --name-only master master@{1} | grep Gemfile | wc -l`.strip.to_i | |
if gems > 0 | |
puts "**************************************************************" | |
puts "**************************************************************" | |
puts "You just pulled changes that included an updated Gemfile." | |
puts "You should run `bundle install` to get the latest gems." | |
puts " " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rake db:migrate && rake db:test:prepare
is handy for copy/paste