ruby-changes:70963
From: David <ko1@a...>
Date: Wed, 19 Jan 2022 15:56:55 +0900 (JST)
Subject: [ruby-changes:70963] 0350c179ea (master): [rubygems/rubygems] Don't pass regexp to `Gem::Dependeny.new` from list, search, and query commands
https://git.ruby-lang.org/ruby.git/commit/?id=0350c179ea From 0350c179ea8c303b6f0087b96478b757052321c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Mon, 17 Jan 2022 14:10:27 +0100 Subject: [rubygems/rubygems] Don't pass regexp to `Gem::Dependeny.new` from list, search, and query commands It's deprecated functionality. https://github.com/rubygems/rubygems/commit/13d3eb6cb0 --- lib/rubygems/commands/list_command.rb | 2 +- lib/rubygems/commands/query_command.rb | 2 +- lib/rubygems/commands/search_command.rb | 2 +- lib/rubygems/query_utils.rb | 16 +++++++--------- test/rubygems/test_gem_command_manager.rb | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index dea11111c96..010d968f9cd 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -10,7 +10,7 @@ class Gem::Commands::ListCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/list_command.rb#L10 def initialize super 'list', 'Display local gems whose name matches REGEXP', - :name => //, :domain => :local, :details => false, :versions => true, + :domain => :local, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default add_query_options diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index 5896bec44e6..442c4b19bb4 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -20,7 +20,7 @@ class Gem::Commands::QueryCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/query_command.rb#L20 def initialize(name = 'query', summary = 'Query gem information in local or remote repositories') super name, summary, - :name => //, :domain => :local, :details => false, :versions => true, + :domain => :local, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default add_option('-n', '--name-matches REGEXP', diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb index 488d7779391..75d99986f91 100644 --- a/lib/rubygems/commands/search_command.rb +++ b/lib/rubygems/commands/search_command.rb @@ -7,7 +7,7 @@ class Gem::Commands::SearchCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/search_command.rb#L7 def initialize super 'search', 'Display remote gems whose name matches REGEXP', - :name => //, :domain => :remote, :details => false, :versions => true, + :domain => :remote, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default add_query_options diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index 4ea1d241ecd..f4cfea30877 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -54,12 +54,12 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L54 end def defaults_str # :nodoc: - "--local --name-matches // --no-details --versions --no-installed" + "--local --no-details --versions --no-installed" end def execute gem_names = if args.empty? - Array(options[:name]) + [options[:name]] else options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i } end @@ -96,7 +96,7 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L96 end def gem_name? - !options[:name].source.empty? + !options[:name].nil? end def prerelease @@ -129,12 +129,10 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L129 display_header("LOCAL") specs = Gem::Specification.find_all do |s| - s.name =~ name and req =~ s.version - end + name_matches = name ? s.name =~ name : true + version_matches = show_prereleases? || !s.version.prerelease? - dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req } - specs.select! do |s| - dep.match?(s.name, s.version, show_prereleases?) + name_matches and version_matches end spec_tuples = specs.map do |spec| @@ -149,7 +147,7 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L147 fetcher = Gem::SpecFetcher.fetcher - spec_tuples = if name.respond_to?(:source) && name.source.empty? + spec_tuples = if name.nil? fetcher.detect(specs_type) { true } else fetcher.detect(specs_type) do |name_tuple| diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index c2e11d20029..ff1f955c6c5 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -252,7 +252,7 @@ class TestGemCommandManager < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_command_manager.rb#L252 Gem::Deprecate.skip_during do @command_manager.process_args %w[query] end - assert_equal(//, check_options[:name]) + assert_nil(check_options[:name]) assert_equal :local, check_options[:domain] assert_equal false, check_options[:details] -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/