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

ruby-changes:69572

From: David <ko1@a...>
Date: Wed, 3 Nov 2021 17:42:57 +0900 (JST)
Subject: [ruby-changes:69572] c5224c71ae (master): [rubygems/rubygems] Fix `gem install` vs `gem fetch` inconsistency

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

From c5224c71aeba147a111131c16688a208c161ee75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sat, 30 Oct 2021 00:20:28 +0200
Subject: [rubygems/rubygems] Fix `gem install` vs `gem fetch` inconsistency

https://github.com/rubygems/rubygems/commit/b3e985799e
---
 lib/rubygems/commands/fetch_command.rb           |  2 +-
 test/rubygems/helper.rb                          | 20 +++++++------
 test/rubygems/test_gem_commands_fetch_command.rb | 36 ++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 619f56a5da6..373851643d4 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -60,7 +60,7 @@ then repackaging it. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/fetch_command.rb#L60
         specs_and_sources = filtered unless filtered.empty?
       end
 
-      spec, source = specs_and_sources.max_by {|s,| s.version }
+      spec, source = specs_and_sources.max_by {|s,| s }
 
       if spec.nil?
         show_lookup_failure gem_name, version, errors, options[:domain]
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index 0fda22b6be2..bbd6380e6fd 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -1072,19 +1072,23 @@ Also, a list: https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L1072
       @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"]     = l_zip
       @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
 
-      v = Gem.marshal_version
-
-      all_specs.each do |spec|
-        path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
-        data = Marshal.dump spec
-        data_deflate = Zlib::Deflate.deflate data
-        @fetcher.data[path] = data_deflate
-      end
+      write_marshalled_gemspecs(*all_specs)
     end
 
     nil # force errors
   end
 
+  def write_marshalled_gemspecs(*all_specs)
+    v = Gem.marshal_version
+
+    all_specs.each do |spec|
+      path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
+      data = Marshal.dump spec
+      data_deflate = Zlib::Deflate.deflate data
+      @fetcher.data[path] = data_deflate
+    end
+  end
+
   ##
   # Deflates +data+
 
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 35ee00f7638..c745648d569 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -79,6 +79,42 @@ class TestGemCommandsFetchCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_fetch_command.rb#L79
                        "#{a2.full_name} not fetched")
   end
 
+  def test_execute_platform
+    a2_spec, a2 = util_gem("a", "2")
+
+    a2_universal_darwin_spec, a2_universal_darwin = util_gem("a", "2") do |s|
+      s.platform = 'universal-darwin'
+    end
+
+    Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
+
+    write_marshalled_gemspecs(a2_spec, a2_universal_darwin_spec)
+
+    @cmd.options[:args] = %w[a]
+
+    @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = util_gzip(Marshal.dump([
+      Gem::NameTuple.new(a2_spec.name, a2_spec.version, a2_spec.platform),
+      Gem::NameTuple.new(a2_universal_darwin_spec.name, a2_universal_darwin_spec.version, a2_universal_darwin_spec.platform),
+    ]))
+
+    @fetcher.data["#{@gem_repo}gems/#{a2_spec.file_name}"] = Gem.read_binary(a2)
+    FileUtils.cp a2, a2_spec.cache_file
+
+    @fetcher.data["#{@gem_repo}gems/#{a2_universal_darwin_spec.file_name}"] = Gem.read_binary(a2_universal_darwin)
+    FileUtils.cp a2_universal_darwin, a2_universal_darwin_spec.cache_file
+
+    util_set_arch 'arm64-darwin20' do
+      use_ui @ui do
+        Dir.chdir @tempdir do
+          @cmd.execute
+        end
+      end
+    end
+
+    assert_path_exist(File.join(@tempdir, a2_universal_darwin_spec.file_name),
+                       "#{a2_universal_darwin_spec.full_name} not fetched")
+  end
+
   def test_execute_specific_prerelease
     specs = spec_fetcher do |fetcher|
       fetcher.gem 'a', 2
-- 
cgit v1.2.1


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

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