Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


A start on the bundle package git support #1

wants to merge 1 commit into from

2 participants


I spent a little time and came up with this. It's likely missing some important functionality because I am not an expert on git (or more importantly, how bundler handles git). But it works great for me.. bundle install catches it and it loads in bundle exec without a problem for my current use case.

The one thing that comes to mind is that branch/tags may not work for this approach.. I'm not sure if that parsing takes place in the install phase (before the repository is added to the gems/bundler/git folder) or if I need to account for it.

In order to avoid a network error when offline, you have to use --local when running bundle package. I'm wondering if this needs to be revised so that it uses the local version if it is unable to retrieve from remote.

Just wanted to get the ball rolling a little bit, because this is a -huge- feature and I feel it will make a lot of peoples' jobs immensely easier! Thanks.


(also, way more tests needed).


Hey awesome. I haven't had a chance to look at this, but soon! Thanks.


Is there anyone on the Bundler side I should send this to? I need someone more familiar with bundler than I am to look at this and let me know if it's even a sane approach to this.


You could fish in #bundler on FreeNode.A couple of the bundler core dudes are generally hanging out in there.


This branch is SUPER out of date, so I'ma just close this.

@benhamill benhamill closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2011
  1. @kyledrake
This page is out of date. Refresh to see the latest.
2  lib/bundler/runtime.rb
@@ -87,7 +87,7 @@ def dependencies_for(*groups)
def cache
- "Updating .gem files in vendor/cache"
+ "Updating .gem and git files in vendor/cache"
specs.each do |spec|
next if == 'bundler'
spec.source.cache(spec) if spec.source.respond_to?(:cache)
21 lib/bundler/source.rb
@@ -469,6 +469,13 @@ def self.from_lock(options)
new(options.merge("uri" => options.delete("remote")))
+ def cache(spec)
+ raise GemNotFound, "Missing git repository for '#{spec.full_name}': '#{cache_path}'." unless cache_path
+ return if, "#{base_name}-#{uri_hash}"))
+ " * #{spec.full_name} revision #{revision}"
+ FileUtils.cp_r cache_path, Bundler.app_cache
+ end
def to_lock
out = "GIT\n"
out << " remote: #{@uri}\n"
@@ -520,7 +527,7 @@ def unlock!
def specs(*)
if allow_git_ops? && !@update
# Start by making sure the git cache is up to date
- cache
+ repository_cache
@update = true
@@ -574,20 +581,24 @@ def shortref_for_path(ref)
def uri_hash
- if uri =~ %r{^\w+://(\w+@)?}
+ if uri.to_s =~ %r{^\w+://(\w+@)?}
# Downcase the domain component of the URI
# and strip off a trailing slash, if one is present
input = URI.parse(uri).normalize.to_s.sub(%r{/$},'')
# If there is no URI scheme, assume it is an ssh/git URI
- input = uri
+ input = uri.to_s
+ def cache_path_scope
+ "#{base_name}-#{uri_hash}"
+ end
def cache_path
@cache_path ||= begin
- git_scope = "#{base_name}-#{uri_hash}"
+ git_scope = cache_path_scope
if Bundler.requires_sudo?
Bundler.user_bundle_path.join("cache/git", git_scope)
@@ -597,7 +608,7 @@ def cache_path
- def cache
+ def repository_cache
if cached?
return if has_revision_cached? "Updating #{uri}"
3  spec/pack/gems_spec.rb
@@ -35,7 +35,8 @@
fit "caches the repository" do
- bundled_app("vendor/cache/foo/").should exist
+ @source = "uri" => lib_path("foo-1.0")
+ bundled_app("vendor/cache/#{@source.send :cache_path_scope}").should exist
Something went wrong with that request. Please try again.