[前][次][番号順一覧][スレッド一覧]

ruby-changes:72391

From: David <ko1@a...>
Date: Sat, 2 Jul 2022 19:41:15 +0900 (JST)
Subject: [ruby-changes:72391] 7b78aba53a (master): [rubygems/rubygems] Account for default gems not having remote when caching

https://git.ruby-lang.org/ruby.git/commit/?id=7b78aba53a

From 7b78aba53aa0b34800bfd96e9e278258d2a890c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 30 Jun 2022 11:55:15 +0200
Subject: [rubygems/rubygems] Account for default gems not having remote when
 caching

https://github.com/rubygems/rubygems/commit/b93d4de2ff
---
 lib/bundler/source/rubygems.rb  | 18 ++++++++++++------
 spec/bundler/cache/gems_spec.rb | 12 ++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 7200f54a9c..a50934b315 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -153,13 +153,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L153
           # Check for this spec from other sources
           uris = [spec.remote, *remotes_for_spec(spec)].map(&:anonymized_uri).uniq
           Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
-
-          path = fetch_gem(spec, options[:previous_spec])
-        else
-          path = cached_gem(spec)
-          raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
         end
 
+        path = fetch_gem_if_possible(spec, options[:previous_spec])
+        raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
+
         return if Bundler.settings[:no_install]
 
         if requires_sudo?
@@ -242,7 +240,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L240
       end
 
       def cache(spec, custom_path = nil)
-        cached_path = Bundler.settings[:cache_all_platforms] ? fetch_gem(spec) : cached_gem(spec)
+        cached_path = Bundler.settings[:cache_all_platforms] ? fetch_gem_if_possible(spec) : cached_gem(spec)
         raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
         return if File.dirname(cached_path) == Bundler.app_cache.to_s
         Bundler.ui.info "  * #{File.basename(cached_path)}"
@@ -462,6 +460,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L460
         end
       end
 
+      def fetch_gem_if_possible(spec, previous_spec = nil)
+        if spec.remote
+          fetch_gem(spec, previous_spec)
+        else
+          cached_gem(spec)
+        end
+      end
+
       def fetch_gem(spec, previous_spec = nil)
         spec.fetch_platform
 
diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb
index a8382a5d8c..63c00eba01 100644
--- a/spec/bundler/cache/gems_spec.rb
+++ b/spec/bundler/cache/gems_spec.rb
@@ -118,6 +118,18 @@ RSpec.describe "bundle cache" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/cache/gems_spec.rb#L118
       expect(bundled_app("vendor/cache/json-#{default_json_version}.gem")).to exist
     end
 
+    it "caches builtin gems when cache_all_platforms is set" do
+      gemfile <<-G
+        source "#{file_uri_for(gem_repo2)}"
+        gem "json"
+      G
+
+      bundle "config set cache_all_platforms true"
+
+      bundle :cache
+      expect(bundled_app("vendor/cache/json-#{default_json_version}.gem")).to exist
+    end
+
     it "doesn't make remote request after caching the gem" do
       build_gem "builtin_gem_2", "1.0.2", :path => bundled_app("vendor/cache") do |s|
         s.summary = "This builtin_gem is bundled with Ruby"
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]