From 0610302a8fc2e2cab401e0afde36dcaffd841cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 7 Jun 2024 11:32:51 +0200 Subject: [rubygems/rubygems] Don't validate local gemspec twice Calling `remote!` or `cached!` on the source was expiring local specs for now reason. It's unnecessary to override these methods for path sources since they only deal with local specifications. https://github.com/rubygems/rubygems/commit/aa93b196a2 --- lib/bundler/source/git.rb | 10 ++++++++++ lib/bundler/source/path.rb | 13 ------------- spec/bundler/install/gemspecs_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 198e335bb6..1eda282e75 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -32,6 +32,16 @@ module Bundler @local = false end + def remote! + @local_specs = nil + @allow_remote = true + end + + def cached! + @local_specs = nil + @allow_cached = true + end + def self.from_lock(options) new(options.merge("uri" => options.delete("remote"))) end diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 978b0b2c9f..754eaa39c4 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -18,9 +18,6 @@ module Bundler @options = options.dup @glob = options["glob"] || DEFAULT_GLOB - @allow_cached = false - @allow_remote = false - @root_path = options["root_path"] || root if options["path"] @@ -41,16 +38,6 @@ module Bundler @original_path = @path end - def remote! - @local_specs = nil - @allow_remote = true - end - - def cached! - @local_specs = nil - @allow_cached = true - end - def self.from_lock(options) new(options.merge("path" => options.delete("remote"))) end diff --git a/spec/bundler/install/gemspecs_spec.rb b/spec/bundler/install/gemspecs_spec.rb index 51aa0ed14f..420b34ca04 100644 --- a/spec/bundler/install/gemspecs_spec.rb +++ b/spec/bundler/install/gemspecs_spec.rb @@ -157,5 +157,25 @@ RSpec.describe "bundle install" do expect(err).to include("but your Gemfile specified") expect(exitstatus).to eq(18) end + + it "validates gemspecs just once when everything installed and lockfile up to date" do + build_lib "foo" + + install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gemspec path: "#{lib_path("foo-1.0")}" + + module Monkey + def validate(spec) + puts "Validate called on \#{spec.full_name}" + end + end + Bundler.rubygems.extend(Monkey) + G + + bundle "install" + + expect(out).to include("Validate called on foo-1.0").once + end end end -- cgit v1.2.3