From 9a4d91fa9507d981a02595d1760628f74396feec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 22 Nov 2024 11:14:08 +0100 Subject: [rubygems/rubygems] Restore previous application cache format for git sources And make sure `bundle install --local` can install from it without git. https://github.com/rubygems/rubygems/commit/7d6b631620 --- lib/bundler/runtime.rb | 5 +++++ lib/bundler/source/git.rb | 24 +++++++++++------------- lib/bundler/source/git/git_proxy.rb | 6 ------ 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index dceb1b1c5a..cfad828e38 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -139,6 +139,11 @@ 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.rm_rf(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 4245585fd7..b7870180f2 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -188,12 +188,10 @@ module Bundler end def specs(*) - set_up_app_cache!(app_cache_path) if use_app_cache? + set_cache_path!(app_cache_path) if use_app_cache? if requires_checkout? && !@copied - FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_repository? - - fetch + fetch unless use_app_cache? checkout end @@ -225,9 +223,7 @@ module Bundler cached! FileUtils.rm_rf(app_cache_path) git_proxy.checkout if requires_checkout? - FileUtils.cp_r("#{cache_path}/.", app_cache_path) - FileUtils.touch(app_cache_path.join(".bundlecache")) - FileUtils.rm_rf(Dir.glob(app_cache_path.join("hooks/*.sample"))) + git_proxy.copy_to(app_cache_path, @submodules) end def load_spec_files @@ -273,7 +269,14 @@ module Bundler def checkout Bundler.ui.debug " * Checking out revision: #{ref}" - git_proxy.copy_to(install_path, submodules) + if use_app_cache? + SharedHelpers.filesystem_access(install_path.dirname) do |p| + FileUtils.mkdir_p(p) + end + FileUtils.cp_r("#{app_cache_path}/.", install_path) + else + git_proxy.copy_to(install_path, submodules) + end serialize_gemspecs_in(install_path) @copied = true end @@ -321,11 +324,6 @@ module Bundler @install_path = path end - def set_up_app_cache!(path) - FileUtils.mkdir_p(path.join("refs")) - set_cache_path!(path) - end - def has_app_cache? locked_revision && super end diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 744235bc04..a73e893829 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -84,12 +84,6 @@ module Bundler end end - def not_a_repository? - _, status = git_null("rev-parse", "--resolve-git-dir", path.to_s, dir: path) - - !status.success? - end - def contains?(commit) allowed_with_path do result, status = git_null("branch", "--contains", commit, dir: path) -- cgit v1.2.3