ruby-changes:70758
From: ximenasandoval <ko1@a...>
Date: Thu, 6 Jan 2022 23:58:51 +0900 (JST)
Subject: [ruby-changes:70758] 73be7a85cd (master): [rubygems/rubygems] Fix suggestions flag
https://git.ruby-lang.org/ruby.git/commit/?id=73be7a85cd From 73be7a85cd4da6229f9a898b77492357e3811210 Mon Sep 17 00:00:00 2001 From: ximenasandoval <ximena.sandoval.dh@g...> Date: Tue, 4 Jan 2022 17:16:40 -0700 Subject: [rubygems/rubygems] Fix suggestions flag https://github.com/rubygems/rubygems/commit/b55a1393ca --- lib/rubygems/commands/fetch_command.rb | 13 +++++++++---- test/rubygems/test_gem_commands_fetch_command.rb | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb index dd45fe20fdf..c8ecb0d48c4 100644 --- a/lib/rubygems/commands/fetch_command.rb +++ b/lib/rubygems/commands/fetch_command.rb @@ -8,7 +8,12 @@ class Gem::Commands::FetchCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/fetch_command.rb#L8 include Gem::VersionOption def initialize - super 'fetch', 'Download a gem and place it in the current directory' + defaults = { + :suggest_alternate => true, + :version => Gem::Requirement.default, + } + + super 'fetch', 'Download a gem and place it in the current directory', defaults add_bulk_threshold_option add_proxy_option @@ -20,7 +25,7 @@ class Gem::Commands::FetchCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/fetch_command.rb#L25 add_prerelease_option add_option '--[no-]suggestions', 'Suggest alternates when gems are not found' do |value, options| - options[:suggest_alternate] = true + options[:suggest_alternate] = value end end @@ -47,7 +52,7 @@ then repackaging it. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/fetch_command.rb#L52 end def check_version # :nodoc: - if options[:version] and options[:version] != Gem::Requirement.default and + if options[:version] != Gem::Requirement.default and get_all_gem_names.size > 1 alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \ " version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`" @@ -66,7 +71,7 @@ then repackaging it. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/fetch_command.rb#L71 gem_version ||= version dep = Gem::Dependency.new gem_name, gem_version dep.prerelease = options[:prerelease] - suppress_suggestions = options[:suggest_alternate] + suppress_suggestions = !options[:suggest_alternate] specs_and_sources, errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb index 550c05b998f..7d4c77afaa3 100644 --- a/test/rubygems/test_gem_commands_fetch_command.rb +++ b/test/rubygems/test_gem_commands_fetch_command.rb @@ -242,7 +242,7 @@ ERROR: Possible alternatives: foo https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_fetch_command.rb#L242 end @cmd.options[:args] = %w[foo:2] - @cmd.options[:suggest_alternate] = true + @cmd.options[:suggest_alternate] = false use_ui @ui do @cmd.execute -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/