Skip to content

Instantly share code, notes, and snippets.

@jamesdabbs
Last active December 14, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamesdabbs/5017797 to your computer and use it in GitHub Desktop.
Save jamesdabbs/5017797 to your computer and use it in GitHub Desktop.
Never again forget to bundle and migrate after merging in changes
#!/usr/bin/env ruby
# Notifies you when certain files are changed which necessitate further action on your part.
#
# To enable:
# - copy this file to .git/hooks/post-merge
# - chmod +x .git/hooks/post-merge
commits = `git reflog -n 2`.lines.map { |l| l.split.first }
changed = `git diff --name-only #{commits.first} #{commits.last}`.lines.map &:strip
actions = {
'Gemfile' => 'bundle',
'db/schema.rb' => 'rake db:migrate'
}.select { |file, action| changed.include?(file) }
unless actions.empty?
puts "\n\e[33mThis merge altered your environment. You should probably"
actions.each do |file, action|
puts "\e[0m* \e[1;33m#{action}"
end
puts "\e[0;33mBe sure to restart resque if needed\e[0m "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment