Skip to content

Instantly share code, notes, and snippets.

@vjt
Created March 23, 2011 11:07
Show Gist options
  • Save vjt/882945 to your computer and use it in GitHub Desktop.
Save vjt/882945 to your computer and use it in GitHub Desktop.
post-checkout hook to recursively checkout Git gem dependencies in Gemfile.lock
#!/usr/bin/env ruby
exit 0 if ARGV[0] == ARGV[1] # Not switching branches
require 'rubygems'
require 'bundler'
require 'pathname'
root = Pathname(Dir.getwd)
lockfile = File.read('Gemfile.lock')
Bundler::LockfileParser.new(lockfile).sources.each do |source|
next unless source.respond_to? :uri
next unless source.uri =~ /ifad\//
$stdout.print "[#{source.uri}] "
$stdout.flush
rev = source.send(:revision)
dir = source.uri.scan(/\/([\w_-]+)\.git$/).to_s
dir = root.join('..', dir)
Dir.chdir dir
%x{ git co #{rev} }
%x{ symlink-gem #{dir} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment