Skip to content

Instantly share code, notes, and snippets.

@vjt
Created March 23, 2012 15:51
Show Gist options
  • Save vjt/2172051 to your computer and use it in GitHub Desktop.
Save vjt/2172051 to your computer and use it in GitHub Desktop.
Rome RSC 2012-03: Develop application and dependent gems, tricking bundler
#!/usr/bin/env ruby
if ARGV[0] == ARGV[1] && $0 =~ /git.*hook/ # Not switching branches
exit 0
end
require 'rubygems'
require 'bundler'
require 'pathname'
root = Pathname(Dir.getwd)
lock = root.join('Gemfile.lock').read
Bundler::LockfileParser.new(lock).sources.each do |source|
next unless source.respond_to? :uri
# If you want to filter on something
#next unless source.uri =~ /vjt\//
$stdout.print "[#{source.uri}] "
$stdout.flush
rev = source.send(:revision)
dir = source.uri.scan(/\/([\w_-]+)\.git$/).first.first
dir = root.join('..', dir)
Dir.chdir dir
symbolic_ref = %x{ git describe --all #{rev} }
symbolic_ref.sub! /^heads\//, ''
%x{ git checkout #{symbolic_ref} }
%x{ symlink-gem #{dir} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment