From 73be7a85cd4da6229f9a898b77492357e3811210 Mon Sep 17 00:00:00 2001 From: ximenasandoval 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 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb index dd45fe20fd..c8ecb0d48c 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 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 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. 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. 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 -- cgit v1.2.3