summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-07-17 09:19:57 +0200
committerJosé Valim <jose.valim@plataformatec.com.br>2012-07-17 09:53:39 +0200
commit51aaf18a0e2d8a76a44f789d0e31b4d2ce123024 (patch)
treea7aa34c6799c4ea58081b528124c67fa15501f63
parent438ef20987951883cb5837d245eac9c517848b2d (diff)
downloadbundler-51aaf18a0e2d8a76a44f789d0e31b4d2ce123024.tar.gz
Don't actually care if git repo is inside the repository, always cache it, closes #1989
-rw-r--r--lib/bundler/source.rb9
-rw-r--r--spec/cache/git_spec.rb18
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 10ade87d86..e4117dd18f 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -694,6 +694,9 @@ module Bundler
File.basename(@uri, '.git')
end
+ # This is the path which is going to contain a specific
+ # checkout of the git repository. When using local git
+ # repos, this is set to the local repo.
def install_path
@install_path ||= begin
git_scope = "#{base_name}-#{shortref_for_path(revision)}"
@@ -778,7 +781,7 @@ module Bundler
def cache(spec)
return unless Bundler.settings[:cache_all]
- return if path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0
+ return if path == app_cache_path
cached!
FileUtils.rm_rf(app_cache_path)
git_proxy.checkout if requires_checkout?
@@ -792,6 +795,10 @@ module Bundler
raise GitError, "#{to_s} is not checked out. Please run `bundle install`"
end
+ # This is the path which is going to contain a cache
+ # of the git repository. When using the same git repository
+ # across different projects, this cache will be shared.
+ # When using local git repos, this is set to the local repo.
def cache_path
@cache_path ||= begin
git_scope = "#{base_name}-#{uri_hash}"
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index 207af1ce26..219d191387 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -30,6 +30,24 @@ end
should_be_installed "foo 1.0"
end
+ it "copies repository to vendor cache and uses it even when installed with bundle --path" do
+ git = build_git "foo"
+ ref = git.ref_for("master", 11)
+
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle "install --path vendor/bundle"
+ bundle "#{cmd} --all"
+
+ bundled_app("vendor/cache/foo-1.0-#{ref}").should exist
+ bundled_app("vendor/cache/foo-1.0-#{ref}/.git").should_not exist
+
+ FileUtils.rm_rf lib_path("foo-1.0")
+ should_be_installed "foo 1.0"
+ end
+
it "runs twice without exploding" do
build_git "foo"