ruby-changes:59231
From: Hiroshi <ko1@a...>
Date: Fri, 13 Dec 2019 20:19:56 +0900 (JST)
Subject: [ruby-changes:59231] 82cc2843a9 (master): Prepare to release RubyGems 3.1.0 final version.
https://git.ruby-lang.org/ruby.git/commit/?id=82cc2843a9 From 82cc2843a92b286cc13afd0860a4e111d4ea2a0b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Fri, 13 Dec 2019 20:19:08 +0900 Subject: Prepare to release RubyGems 3.1.0 final version. diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 474734b..6be55a0 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -160,24 +160,14 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L160 ].freeze ## - # Exception classes used in a Gem.read_binary +rescue+ statement. Not all of - # these are defined in Ruby 1.8.7, hence the need for this convoluted setup. + # Exception classes used in a Gem.read_binary +rescue+ statement - READ_BINARY_ERRORS = begin - read_binary_errors = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS] - read_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP) - read_binary_errors - end.freeze + READ_BINARY_ERRORS = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS, Errno::ENOTSUP].freeze ## - # Exception classes used in Gem.write_binary +rescue+ statement. Not all of - # these are defined in Ruby 1.8.7. + # Exception classes used in Gem.write_binary +rescue+ statement - WRITE_BINARY_ERRORS = begin - write_binary_errors = [Errno::ENOSYS] - write_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP) - write_binary_errors - end.freeze + WRITE_BINARY_ERRORS = [Errno::ENOSYS, Errno::ENOTSUP].freeze @@win_platform = nil diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index ab683f0..c1e5e13 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -369,22 +369,44 @@ class Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L369 end end - def deprecate_option(short_name: nil, long_name: nil, version: nil) - @deprecated_options[command].merge!({ short_name => { "rg_version_to_expire" => version } }) if short_name - @deprecated_options[command].merge!({ long_name => { "rg_version_to_expire" => version } }) if long_name + ## + # Mark a command-line option as deprecated, and optionally specify a + # deprecation horizon. + # + # Note that with the current implementation, every version of the option needs + # to be explicitly deprecated, so to deprecate an option defined as + # + # add_option('-t', '--[no-]test', 'Set test mode') do |value, options| + # # ... stuff ... + # end + # + # you would need to explicitly add a call to `deprecate_option` for every + # version of the option you want to deprecate, like + # + # deprecate_option('-t') + # deprecate_option('--test') + # deprecate_option('--no-test') + + def deprecate_option(name, version: nil, extra_msg: nil) + @deprecated_options[command].merge!({ name => { "rg_version_to_expire" => version, "extra_msg" => extra_msg } }) end def check_deprecated_options(options) options.each do |option| if option_is_deprecated?(option) - version_to_expire = @deprecated_options[command][option]["rg_version_to_expire"] + deprecation = @deprecated_options[command][option] + version_to_expire = deprecation["rg_version_to_expire"] deprecate_option_msg = if version_to_expire - "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}, its use is discouraged." + "The \"#{option}\" option has been deprecated and will be removed in Rubygems #{version_to_expire}." else - "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems, its use is discouraged." + "The \"#{option}\" option has been deprecated and will be removed in future versions of Rubygems." end + extra_msg = deprecation["extra_msg"] + + deprecate_option_msg += " #{extra_msg}" if extra_msg + alert_warning(deprecate_option_msg) end end diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index 941637e..6dccdcb 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -25,6 +25,9 @@ class Gem::Commands::GenerateIndexCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/generate_index_command.rb#L25 options[:build_modern] = value end + deprecate_option('--modern', version: '4.0', extra_msg: 'Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.') + deprecate_option('--no-modern', version: '4.0', extra_msg: 'The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.') + add_option '--update', 'Update modern indexes with gems added', 'since the last update' do |value, options| diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 3448fdf..7844e9d 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -98,7 +98,7 @@ class Gem::Commands::SetupCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L98 end def check_ruby_version - required_version = Gem::Requirement.new '>= 1.8.7' + required_version = Gem::Requirement.new '>= 2.3.0' unless required_version.satisfied_by? Gem.ruby_version alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}" diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb index af145fd..feab232 100644 --- a/lib/rubygems/commands/sources_command.rb +++ b/lib/rubygems/commands/sources_command.rb @@ -43,6 +43,8 @@ class Gem::Commands::SourcesCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/sources_command.rb#L43 source = Gem::Source.new source_uri + check_typo_squatting(source) + begin if Gem.sources.include? source say "source #{source_uri} already present in the cache" @@ -62,6 +64,18 @@ class Gem::Commands::SourcesCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/sources_command.rb#L64 end end + def check_typo_squatting(source) + if source.typo_squatting?("rubygems.org") + question = <<-QUESTION.chomp +#{source.uri.to_s} is too similar to https://rubygems.org + +Do you want to add this source? + QUESTION + + terminate_interaction 1 unless ask_yes_no question + end + end + def check_rubygems_https(source_uri) # :nodoc: uri = URI source_uri diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb index 96da272..6ea72b1 100644 --- a/lib/rubygems/core_ext/kernel_warn.rb +++ b/lib/rubygems/core_ext/kernel_warn.rb @@ -6,13 +6,17 @@ if RUBY_VERSION >= "2.5" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_warn.rb#L6 module Kernel path = "#{__dir__}/" # Frames to be skipped start with this path. - # Suppress "method redefined" warning - original_warn = instance_method(:warn) - Module.new {define_method(:warn, original_warn)} - original_warn = method(:warn) - module_function define_method(:warn) {|*messages, **kw| + remove_method :warn + + class << self + + remove_method :warn + + end + + define_method(:warn) do |*messages, **kw| unless uplevel = kw[:uplevel] if Gem.java_platform? return original_warn.call(*messages) @@ -46,6 +50,6 @@ if RUBY_VERSION >= "2.5" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_warn.rb#L50 kw[:uplevel] = uplevel original_warn.call(*messages, **kw) - } + end end end diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index d91ecd2..2fc1074 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -6,7 +6,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L6 #++ require 'rubygems/user_interaction' -require "open3" class Gem::Ext::Builder @@ -68,6 +67,7 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L67 results << "current directory: #{Dir.pwd}" results << (command.respond_to?(:shelljoin) ? command.shelljoin : command) + require "open3" output, status = Open3.capture2e(*command) if verbose puts output diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index c399cc9..2ed619f 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -4,6 +4,7 @@ require 'rubygems/request' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L4 require 'rubygems/request/connection_pools' require 'rubygems/s3_uri_signer' require 'rubygems/uri_formatter' +require 'rubygems/uri_parsing' require 'rubygems/user_interaction' require 'resolv' require 'rubygems/deprecate' @@ -17,12 +18,16 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L18 include Gem::UserInteraction extend Gem::Deprecate + include Gem::UriParsing + ## # A FetchError exception wraps up the various possible IO and HTTP failures # that could happen while downloading from the internet. class FetchError < Gem::Exception + include Gem::UriParsing + ## # The URI which was being accessed when the exception happened. @@ -30,13 +35,12 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L35 def initialize(message, uri) super message - begin - uri = URI(uri) - uri.password = 'REDACTED' if uri.password - @uri = uri.to_s - (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/