From 4b44590d390f59dbf4d0cb922618ff5cc5b5411a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 17 Mar 2021 17:41:25 +0100 Subject: [PATCH] [rubygems/rubygems] Keep only the bare clone in the per app cache We don't need an actual checkout since the cache path is no longer used as the install location. Now the per app cache acts just like the standard cache. https://github.com/rubygems/rubygems/commit/686988923c --- lib/bundler/runtime.rb | 4 ---- lib/bundler/source/git.rb | 3 ++- spec/bundler/cache/git_spec.rb | 5 +++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 6df5981cd5..9792a81962 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -139,10 +139,6 @@ module Bundler spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache) end - Dir[cache_path.join("*/.git")].each do |git_dir| - FileUtils.touch(File.expand_path("../.bundlecache", git_dir)) - end - prune_cache(cache_path) unless Bundler.settings[:no_prune] end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 8ee3f6600e..3f69ea1e65 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -222,7 +222,8 @@ module Bundler cached! FileUtils.rm_rf(app_cache_path) git_proxy.checkout if requires_checkout? - git_proxy.copy_to(app_cache_path, @submodules) + FileUtils.cp_r("#{cache_path}/.", app_cache_path) + FileUtils.touch(app_cache_path.join(".bundlecache")) end def load_spec_files diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb index 13ed6a6f39..8d7e449e30 100644 --- a/spec/bundler/cache/git_spec.rb +++ b/spec/bundler/cache/git_spec.rb @@ -25,6 +25,7 @@ RSpec.describe "bundle cache with git" do bundle "config set cache_all true" bundle :cache expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist + expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file FileUtils.rm_rf lib_path("foo-1.0") @@ -46,6 +47,7 @@ RSpec.describe "bundle cache with git" do bundle :cache expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist + expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist FileUtils.rm_rf lib_path("foo-1.0") expect(the_bundle).to include_gems "foo 1.0" @@ -209,7 +211,7 @@ RSpec.describe "bundle cache with git" do expect(the_bundle).to include_gem "foo 1.0" end - it "copies repository to vendor cache, including submodules" do + it "copies repository to vendor cache" do # CVE-2022-39253: https://lore.kernel.org/lkml/xmqq4jw1uku5.fsf@gitster.g/ system(*%W[git config --global protocol.file.allow always]) @@ -234,7 +236,6 @@ RSpec.describe "bundle cache with git" do bundle :cache expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist - expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist expect(the_bundle).to include_gems "has_submodule 1.0" end