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

ruby-changes:64019

From: Hiroshi <ko1@a...>
Date: Tue, 8 Dec 2020 17:30:21 +0900 (JST)
Subject: [ruby-changes:64019] 4aca77edde (master): Merge prepare version of RubyGems 3.2.0

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

From 4aca77edde91f826aa243e268bf1ef5214530583 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 8 Dec 2020 16:33:39 +0900
Subject: Merge prepare version of RubyGems 3.2.0


diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index eabe1c4..e6a3c63 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L8
 require 'rbconfig'
 
 module Gem
-  VERSION = "3.2.0.rc.2".freeze
+  VERSION = "3.2.0".freeze
 end
 
 # Must be first since it unloads the prelude from 1.9.2
@@ -119,6 +119,10 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L119
   # to avoid deprecation warnings in Ruby 2.7.
   UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{}
 
+  # When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
+  KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||
+      (RUBY_ENGINE == "ruby" && RUBY_VERSION >= '3.0')
+
   ##
   # An Array of Regexps that match windows Ruby platforms.
 
@@ -975,7 +979,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L979
                      val = RbConfig::CONFIG[key]
                      next unless val and not val.empty?
                      ".#{val}"
-                   end
+                   end,
                   ].compact.uniq
   end
 
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index 80ef29d..499483d 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -73,7 +73,7 @@ class Gem::AvailableSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L73
   end
 
   def match_platform!
-    @set.reject! {|t| !Gem::Platform.match(t.spec.platform) }
+    @set.reject! {|t| !Gem::Platform.match_spec?(t.spec) }
     @sorted = nil
     self
   end
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 1dcb577..97e5254 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -73,7 +73,7 @@ class Gem::CommandManager https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command_manager.rb#L73
   ].freeze
 
   ALIAS_COMMANDS = {
-    'i' => 'install'
+    'i' => 'install',
   }.freeze
 
   ##
@@ -174,8 +174,8 @@ class Gem::CommandManager https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command_manager.rb#L174
     else
       cmd_name = args.shift.downcase
       cmd = find_command cmd_name
-      cmd.invoke_with_build_args args, build_args
       cmd.deprecation_warning if cmd.deprecated?
+      cmd.invoke_with_build_args args, build_args
     end
   end
 
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index eaf8573..fff5f7c 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -61,14 +61,18 @@ Gems can be saved to a specified filename with the output option: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L61
   end
 
   def execute
-    gem_name = get_one_optional_argument || find_gemspec
-    build_gem(gem_name)
+    if build_path = options[:build_path]
+      Dir.chdir(build_path) { build_gem }
+      return
+    end
+
+    build_gem
   end
 
   private
 
-  def find_gemspec
-    gemspecs = Dir.glob("*.gemspec").sort
+  def find_gemspec(glob = "*.gemspec")
+    gemspecs = Dir.glob(glob).sort
 
     if gemspecs.size > 1
       alert_error "Multiple gemspecs found: #{gemspecs}, please specify one"
@@ -78,28 +82,19 @@ Gems can be saved to a specified filename with the output option: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L82
     gemspecs.first
   end
 
-  def build_gem(gem_name)
-    gemspec = File.exist?(gem_name) ? gem_name : "#{gem_name}.gemspec"
-
-    if File.exist?(gemspec)
-      spec = Gem::Specification.load(gemspec)
-
-      if options[:build_path]
-        Dir.chdir(File.dirname(gemspec)) do
-          spec = Gem::Specification.load(File.basename(gemspec))
-          build_package(spec)
-        end
-      else
-        build_package(spec)
-      end
+  def build_gem
+    gemspec = resolve_gem_name
 
+    if gemspec
+      build_package(gemspec)
     else
-      alert_error "Gemspec file not found: #{gemspec}"
+      alert_error error_message
       terminate_interaction(1)
     end
   end
 
-  def build_package(spec)
+  def build_package(gemspec)
+    spec = Gem::Specification.load(gemspec)
     if spec
       Gem::Package.build(
         spec,
@@ -112,4 +107,26 @@ Gems can be saved to a specified filename with the output option: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L107
       terminate_interaction 1
     end
   end
+
+  def resolve_gem_name
+    return find_gemspec unless gem_name
+
+    if File.exist?(gem_name)
+      gem_name
+    else
+      find_gemspec("#{gem_name}.gemspec") || find_gemspec(gem_name)
+    end
+  end
+
+  def error_message
+    if gem_name
+      "Couldn't find a gemspec file matching '#{gem_name}' in #{Dir.pwd}"
+    else
+      "Couldn't find a gemspec file in #{Dir.pwd}"
+    end
+  end
+
+  def gem_name
+    get_one_optional_argument
+  end
 end
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index e5355d3..998df06 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -311,4 +311,4 @@ For further reading on signing gems see `ri Gem::Security`. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cert_command.rb#L311
     # It's simple, but is all we need
     email =~ /\A.+@.+\z/
   end
-end if defined?(OpenSSL::SSL)
+end if Gem::HAVE_OPENSSL
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 9ba8bf1..4e8d760 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -332,6 +332,8 @@ platform. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/help_command.rb#L332
     @command_manager.command_names.each do |cmd_name|
       command = @command_manager[cmd_name]
 
+      next if command.deprecated?
+
       summary =
         if command
           command.summary
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 0f01823..4617285 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -53,7 +53,7 @@ permission to. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/owner_command.rb#L53
   def execute
     @host = options[:host]
 
-    sign_in
+    sign_in(scope: get_owner_scope)
     name = get_one_gem_name
 
     add_owners    name, options[:add]
@@ -102,10 +102,18 @@ permission to. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/owner_command.rb#L102
   private
 
   def send_owner_request(method, name, owner)
-    rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
+    rubygems_api_request method, "api/v1/gems/#{name}/owners", scope: get_owner_scope(method: method) do |request|
       request.set_form_data 'email' => owner
       request.add_field "Authorization", api_key
       request.add_field "OTP", options[:otp] if options[:otp]
     end
   end
+
+  def get_owner_scope(method: nil)
+    if method == :post || options.any? && options[:add].any?
+      :add_owner
+    elsif method == :delete || options.any? && options[:remove].any?
+      :remove_owner
+    end
+  end
 end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index db8136c..1431059 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -170,7 +170,7 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L170
         :install_dir => spec.base_dir,
         :env_shebang => env_shebang,
         :build_args => spec.build_args,
-        :bin_dir => bin_dir
+        :bin_dir => bin_dir,
       }
 
       if options[:only_executables]
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 003b2da..8885269 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -61,7 +61,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/push_command.rb#L61
               options[:host]
             end
 
-    sign_in @host
+    sign_in @host, scope: get_push_scope
 
     send_gem(gem_name)
   end
@@ -86,7 +86,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/push_command.rb#L86
   private
 
   def send_push_request(name, args)
-    rubygems_api_request(*args) do |request|
+    rubygems_api_request(*args, scope: get_push_scope) do |request|
       request.body = Gem.read_binary name
       request.add_field "Content-Length", request.body.size
       request.add_field "Content-Type",   "application/octet-stream"
@@ -100,7 +100,11 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/push_command.rb#L100
 
     [
       gem_metadata["default_gem_server"],
-      gem_metadata["allowed_push_host"]
+      gem_metadata["allowed_push_host"],
     ]
   end
+
+  def get_push_scope
+    :push_rubygem
+  end
 end
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 406a34e..789afd6 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -9,6 +9,14 @@ class Gem::Commands::QueryCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/query_command.rb#L9
 
   include Gem::QueryUtils
  (... truncated)

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

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