Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

A start on the bundle package git support #1

Closed
wants to merge 1 commit into from

2 participants

@kyledrake

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.

@kyledrake

(also, way more tests needed).

@benhamill
Owner

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

@kyledrake

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.

@benhamill
Owner

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

@benhamill
Owner

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.
View
2  lib/bundler/runtime.rb
@@ -87,7 +87,7 @@ def dependencies_for(*groups)
def cache
FileUtils.mkdir_p(cache_path)
- Bundler.ui.info "Updating .gem files in vendor/cache"
+ Bundler.ui.info "Updating .gem and git files in vendor/cache"
specs.each do |spec|
next if spec.name == 'bundler'
spec.source.cache(spec) if spec.source.respond_to?(:cache)
View
21 lib/bundler/source.rb
@@ -469,6 +469,13 @@ def self.from_lock(options)
new(options.merge("uri" => options.delete("remote")))
end
+ def cache(spec)
+ raise GemNotFound, "Missing git repository for '#{spec.full_name}': '#{cache_path}'." unless cache_path
+ return if File.directory?(File.join(Bundler.app_cache, "#{base_name}-#{uri_hash}"))
+ Bundler.ui.info " * #{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
checkout
@update = true
end
@@ -574,20 +581,24 @@ def shortref_for_path(ref)
end
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{/$},'')
else
# If there is no URI scheme, assume it is an ssh/git URI
- input = uri
+ input = uri.to_s
end
Digest::SHA1.hexdigest(input)
end
+ 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
end
end
- def cache
+ def repository_cache
if cached?
return if has_revision_cached?
Bundler.ui.info "Updating #{uri}"
View
3  spec/pack/gems_spec.rb
@@ -35,7 +35,8 @@
end
fit "caches the repository" do
- bundled_app("vendor/cache/foo/").should exist
+ @source = Bundler::Source::Git.new "uri" => lib_path("foo-1.0")
+ bundled_app("vendor/cache/#{@source.send :cache_path_scope}").should exist
end
end
Something went wrong with that request. Please try again.