diff options
-rw-r--r-- | lib/bundler.rb | 4 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 8 | ||||
-rw-r--r-- | spec/commands/clean_spec.rb | 9 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 15 |
4 files changed, 21 insertions, 15 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index edef1620e8..5eb2d1bca4 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -207,10 +207,6 @@ module Bundler bundle_path.join("specifications") end - def cache - bundle_path.join("cache/bundler") - end - def user_cache user_bundle_path.join("cache") end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index eb605771f4..fd8f6debea 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -211,11 +211,11 @@ module Bundler @cache_path ||= begin git_scope = "#{base_name}-#{uri_hash}" - if Bundler.requires_sudo? - Bundler.user_bundle_path.join("cache/git", git_scope) + if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache? + Bundler.user_cache else - Bundler.cache.join("git", git_scope) - end + Bundler.bundle_path.join("cache", "bundler") + end.join("git", git_scope) end end diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 9be8f24fda..be8f80065c 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -142,7 +142,8 @@ RSpec.describe "bundle clean" do bundle :clean digest = Digest::SHA1.hexdigest(git_path.to_s) - expect(vendored_gems("cache/bundler/git/foo-1.0-#{digest}")).to exist + cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") + expect(cache_path).to exist end it "removes unused git gems" do @@ -671,7 +672,7 @@ RSpec.describe "bundle clean" do gem "foo" G - bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false) + bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false) gemfile <<-G source "file://#{gem_repo1}" @@ -680,8 +681,8 @@ RSpec.describe "bundle clean" do gem "weakling" G - bundle "config auto_install 1" - bundle :clean + bundle! "config auto_install 1" + bundle! :clean expect(out).to include("Installing weakling 0.0.3") should_have_gems "thin-1.0", "rack-1.0.0", "weakling-0.0.3" should_not_have_gems "foo-1.0" diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index a3e69325cc..feafb568dd 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -26,8 +26,15 @@ RSpec.describe "bundle install with git sources" do expect(out).to eq("WIN") end - it "caches the git repo" do - expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"].size).to eq(1) + it "caches the git repo", :bundler => "< 2" do + expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1 + end + + it "caches the git repo globally" do + simulate_new_machine + bundle! "config global_gem_cache true" + bundle! :install + expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes :size => 1 end it "caches the evaluated gemspec" do @@ -278,6 +285,8 @@ RSpec.describe "bundle install with git sources" do sys_exec!("git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1") end + bundle! "config global_gem_cache true" + install_gemfile! <<-G git "#{lib_path("foo-1.0")}" do gem "foo" @@ -287,7 +296,7 @@ RSpec.describe "bundle install with git sources" do # ensure we also git fetch after cloning bundle! :update, :all => bundle_update_requires_all? - Dir.chdir(Dir[default_bundle_path("cache/bundler/git/foo-*")].first) do + Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do sys_exec("git ls-remote .") end |