Skip to content

Instantly share code, notes, and snippets.

@devdatta
Forked from mislav/instructions.md
Created June 25, 2010 17:32
Show Gist options
  • Save devdatta/453160 to your computer and use it in GitHub Desktop.
Save devdatta/453160 to your computer and use it in GitHub Desktop.

Copy this script to ".git/hooks/post-checkout" in your repository and make it executable:

chmod +x .git/hooks/post-checkout

Tweak it at will. I'm refreshing the bundle and restarting the app server because the Gemfile is different on my "hosted" branch than on other branches.

#!/usr/bin/env ruby -wKU
old, head, flag = ARGV
# your branch name here
target_branch = 'hosted'
if flag == "1" # switching branches
branches = `git name-rev --name-only #{old} #{head}`.split("\n")
if branches.include?(target_branch)
puts 'checking bundle, restarting app ...'
system 'bundle check'
system 'touch tmp/restart.txt'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment