From 51aaf18a0e2d8a76a44f789d0e31b4d2ce123024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 17 Jul 2012 09:19:57 +0200 Subject: Don't actually care if git repo is inside the repository, always cache it, closes #1989 --- lib/bundler/source.rb | 9 ++++++++- spec/cache/git_spec.rb | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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" -- cgit v1.2.1