[rubygems/rubygems] Stop using the cache path as the install location

https://github.com/rubygems/rubygems/commit/ecadd02746
This commit is contained in:
David Rodríguez 2021-03-18 13:26:50 +01:00 коммит произвёл git
Родитель a4ec5f8747
Коммит a7657b0106
3 изменённых файлов: 92 добавлений и 4 удалений

Просмотреть файл

@ -188,7 +188,7 @@ module Bundler
end
def specs(*)
set_paths!(app_cache_path) if has_app_cache? && !local?
set_cache_path!(app_cache_path) if has_app_cache? && !local?
if requires_checkout? && !@copied
fetch
@ -218,6 +218,7 @@ module Bundler
app_cache_path = app_cache_path(custom_path)
return unless Bundler.feature_flag.cache_all?
return if install_path == app_cache_path
return if cache_path == app_cache_path
cached!
FileUtils.rm_rf(app_cache_path)
git_proxy.checkout if requires_checkout?

87
spec/bundler/cache/git_spec.rb поставляемый
Просмотреть файл

@ -152,6 +152,63 @@ RSpec.describe "bundle cache with git" do
expect(out).to eq("LOCAL")
end
it "can use gems after copying install folder to a different machine with git not installed" do
build_git "foo"
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set path vendor/bundle"
bundle :install
simulate_new_machine
with_path_as "" do
bundle "config set deployment true"
bundle "install --local"
expect(the_bundle).to include_gem "foo 1.0"
end
end
it "can install after bundle cache without cloning remote repositories" do
build_git "foo"
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/foo-1.0-*")).first.to_s
simulate_new_machine
bundle "config set frozen true"
bundle "install --local --verbose"
expect(out).to_not include("Fetching")
expect(the_bundle).to include_gem "foo 1.0"
end
it "can install after bundle cache without cloning remote repositories even without the original cache" do
build_git "foo"
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/foo-1.0-*")).first.to_s
simulate_new_machine
bundle "config set frozen true"
FileUtils.rm_rf "#{default_bundle_path}/cache/bundler/git/foo-1.0-*"
bundle "install --local --verbose"
expect(out).to_not include("Fetching")
expect(the_bundle).to include_gem "foo 1.0"
end
it "copies repository to vendor cache, including submodules" do
# CVE-2022-39253: https://lore.kernel.org/lkml/xmqq4jw1uku5.fsf@gitster.g/
system(*%W[git config --global protocol.file.allow always])
@ -208,6 +265,7 @@ RSpec.describe "bundle cache with git" do
source "https://gem.repo1"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set path vendor/bundle"
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true, :install => false
@ -271,4 +329,33 @@ RSpec.describe "bundle cache with git" do
R
expect(last_command).to_not be_failure
end
it "doesn't fail when git gem has extensions and an empty cache folder is present before bundle install" do
build_git "puma" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
s.executables = "puma"
s.write "Rakefile", <<-RUBY
task :default do
path = File.expand_path("../lib", __FILE__)
FileUtils.mkdir_p(path)
File.open("\#{path}/puma.rb", "w") do |f|
f.puts "PUMA = 'YES'"
end
end
RUBY
end
FileUtils.mkdir_p(bundled_app("vendor/cache"))
bundle "config set cache_all all"
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "puma", :git => "#{lib_path("puma-1.0")}"
G
bundle "exec puma"
expect(out).to eq("YES")
end
end

Просмотреть файл

@ -1549,7 +1549,7 @@ In Gemfile:
to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
end
it "installs a packaged git gem successfully" do
it "doesn't need git in the new machine if an installed git gem is copied to another machine" do
build_git "foo"
install_gemfile <<-G
@ -1558,8 +1558,8 @@ In Gemfile:
gem 'foo'
end
G
bundle "config set cache_all true"
bundle :cache
bundle "config set --global path vendor/bundle"
bundle :install
simulate_new_machine
bundle "install", env: { "PATH" => "" }