From 5dbc6583c93621a7e992163bd27991bd3d3d9378 Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 28 Nov 2018 03:08:14 +0000 Subject: Merge rubygems upstream from https://github.com/rubygems/rubygems/commit/2c499655f29070c809dfea9f5fda6fac6850e62e https://github.com/rubygems/rubygems/pull/2493 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/install_command.rb | 2 +- lib/rubygems/commands/pristine_command.rb | 5 ----- lib/rubygems/commands/uninstall_command.rb | 21 +++++++++++++++++---- lib/rubygems/installer.rb | 10 +++++----- lib/rubygems/specification.rb | 10 ---------- 5 files changed, 23 insertions(+), 25 deletions(-) (limited to 'lib/rubygems') diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index fca14681ee..776b58651f 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -142,7 +142,7 @@ You can use `i` command instead of `install`. 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 requirments using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`" + " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`" terminate_interaction 1 end end diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index b686d8341d..41decde856 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -129,11 +129,6 @@ extensions will be restored. end end - if spec.bundled_gem_in_old_ruby? - say "Skipped #{spec.full_name}, it is bundled with old Ruby" - next - end - unless spec.extensions.empty? or options[:extensions] or options[:only_executables] say "Skipped #{spec.full_name}, it needs to compile an extension" next diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 3f975ce3bc..9de0ea722b 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -114,7 +114,18 @@ that is a dependency of an existing gem. You can use the "#{program_name} GEMNAME [GEMNAME ...]" end + def check_version # :nodoc: + 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 uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`" + terminate_interaction 1 + end + end + def execute + check_version + if options[:all] and not options[:args].empty? uninstall_specific elsif options[:all] @@ -138,8 +149,9 @@ that is a dependency of an existing gem. You can use the def uninstall_specific deplist = Gem::DependencyList.new - get_all_gem_names.uniq.each do |name| - gem_specs = Gem::Specification.find_all_by_name(name) + get_all_gem_names_and_versions.each do |name, version| + requirement = Array(version || options[:version]) + gem_specs = Gem::Specification.find_all_by_name(name, *requirement) say("Gem '#{name}' is not installed") if gem_specs.empty? gem_specs.each do |spec| deplist.add spec @@ -148,8 +160,9 @@ that is a dependency of an existing gem. You can use the deps = deplist.strongly_connected_components.flatten.reverse - deps.map(&:name).uniq.each do |gem_name| - uninstall_gem(gem_name) + deps.each do |dep| + options[:version] = dep.version + uninstall_gem(dep.name) end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 3c2a2ac3c2..b1f83174bd 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -749,11 +749,11 @@ require 'rubygems' version = "#{Gem::Requirement.default}.a" -if ARGV.first - str = ARGV.first - str = str.dup.force_encoding("BINARY") - if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) - version = $1 +str = ARGV.first +if str + str = str.b[/\\A_(.*)_\\z/, 1] + if str and Gem::Version.correct?(str) + version = str ARGV.shift end end diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 4721bfc415..7eaa509d2b 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -1660,16 +1660,6 @@ class Gem::Specification < Gem::BasicSpecification File.join build_info_dir, "#{full_name}.info" end - ## - # Used to detect if the gem is bundled in older version of Ruby, but not - # detectable as default gem (see BasicSpecification#default_gem?). - - def bundled_gem_in_old_ruby? - !default_gem? && - RUBY_VERSION < "2.0.0" && - summary == "This #{name} is bundled with Ruby" - end - ## # Returns the full path to the cache directory containing this # spec's cached gem. -- cgit v1.2.3