diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-28 03:08:14 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-28 03:08:14 +0000 |
commit | 5dbc6583c93621a7e992163bd27991bd3d3d9378 (patch) | |
tree | 93d60f32d81d9ee58b538586f44acccbbc27c230 /lib/rubygems/commands/uninstall_command.rb | |
parent | b52761e4f71326099374515e494b1667b2bbf84b (diff) | |
download | ruby-5dbc6583c93621a7e992163bd27991bd3d3d9378.tar.gz |
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
Diffstat (limited to 'lib/rubygems/commands/uninstall_command.rb')
-rw-r--r-- | lib/rubygems/commands/uninstall_command.rb | 21 |
1 files changed, 17 insertions, 4 deletions
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 |