Skip to content

Instantly share code, notes, and snippets.

@chadbailey59
Last active December 11, 2015 22:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadbailey59/4670369 to your computer and use it in GitHub Desktop.
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.
#!/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
@eprothro
Copy link

rake db:migrate && rake db:test:prepare is handy for copy/paste

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