aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-07-11 20:33:33 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-07-13 11:36:03 +0900
commitc1fb25f6fc7427c25839493a6edd63199b794fdc (patch)
tree8ffa8b7c986cf13eaa3a1534756e83cca0b89d87 /spec
parent8cf5297ba595af38a89ba8d2d428ae26b6bb00d2 (diff)
downloadruby-c1fb25f6fc7427c25839493a6edd63199b794fdc.tar.gz
[rubygems/rubygems] Don't run any git commands when sorting and comparing git sources
Previously, when sorting and comparing git Gemfile vs lockfile sources during `bundler/setup` to figure out whether we need to re-resolve or not, we would try to find the default branch if nothing more specific was specified in the Gemfile. If the git cache has been deleted thought, that would fail. The error would still be swallowed (and the branch would simply not be displayed), but trying to clone would still generate the side effect of creating the parent folder for the clone. That could affect non-writable systems that don't expect `bundler/setup` to write to the filesystem at all. To fix this, override `Bundler::Source::Git#identifier` to use exclusively static information, so it does not even try to clone the repo nor generate any side effects. https://github.com/rubygems/rubygems/commit/582eb2ef39
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index c96a78bc1c..910f96f4ab 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -30,6 +30,13 @@ RSpec.describe "bundle install with git sources" do
expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1
end
+ it "does not write to cache on bundler/setup" do
+ cache_path = default_bundle_path.join("cache")
+ FileUtils.rm_rf(cache_path)
+ ruby "require 'bundler/setup'"
+ expect(cache_path).not_to exist
+ end
+
it "caches the git repo globally and properly uses the cached repo on the next invocation" do
simulate_new_machine
bundle "config set global_gem_cache true"