mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
[rubygems/rubygems] Allow uninstalling multiple versions of same gem
Currently, you can install multiple versions of the same gem just fine:
```
$ gem install simplecov:0.19.0 simplecov:0.22.0
Fetching simplecov-0.19.0.gem
Successfully installed simplecov-0.19.0
Parsing documentation for simplecov-0.19.0
Installing ri documentation for simplecov-0.19.0
Done installing documentation for simplecov after 0 seconds
Fetching simplecov-0.22.0.gem
Successfully installed simplecov-0.22.0
Parsing documentation for simplecov-0.22.0
Installing ri documentation for simplecov-0.22.0
Done installing documentation for simplecov after 0 seconds
2 gems installed
```
But to uninstall both of them, you need to run the equivalent uninstall
command twice:
```
~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0
Successfully uninstalled simplecov-0.22.0
~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0
Gem 'simplecov' is not installed
Successfully uninstalled simplecov-0.19.0
```
This resolves that problem by using the gem's full name (which includes
the version) when tracking which ones have already been uninstalled so
when it gets to the second version listed it doesn't think it was
already uninstalled.
d96101b753
This commit is contained in:
parent
8e6a251138
commit
ef3f9f1a68
2 changed files with 24 additions and 4 deletions
|
@ -168,10 +168,10 @@ that is a dependency of an existing gem. You can use the
|
||||||
gems_to_uninstall = {}
|
gems_to_uninstall = {}
|
||||||
|
|
||||||
deps.each do |dep|
|
deps.each do |dep|
|
||||||
next if gems_to_uninstall[dep.name]
|
if original_gem_version[dep.name] == Gem::Requirement.default
|
||||||
gems_to_uninstall[dep.name] = true
|
next if gems_to_uninstall[dep.name]
|
||||||
|
gems_to_uninstall[dep.name] = true
|
||||||
unless original_gem_version[dep.name] == Gem::Requirement.default
|
else
|
||||||
options[:version] = dep.version
|
options[:version] = dep.version
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,26 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
|
||||||
assert File.exist? File.join(@gemhome, "bin", "executable")
|
assert File.exist? File.join(@gemhome, "bin", "executable")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_execute_with_multiple_version_specified_as_colon
|
||||||
|
initial_install
|
||||||
|
|
||||||
|
ui = Gem::MockGemUi.new "y\n"
|
||||||
|
|
||||||
|
util_make_gems
|
||||||
|
|
||||||
|
assert_equal 3, Gem::Specification.find_all_by_name("a").length
|
||||||
|
|
||||||
|
@cmd.options[:force] = true
|
||||||
|
@cmd.options[:args] = ["a:1", "a:2"]
|
||||||
|
|
||||||
|
use_ui ui do
|
||||||
|
@cmd.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 1, Gem::Specification.find_all_by_name("a").length
|
||||||
|
assert_equal Gem::Version.new("3.a"), Gem::Specification.find_by_name("a").version
|
||||||
|
end
|
||||||
|
|
||||||
def test_uninstall_selection
|
def test_uninstall_selection
|
||||||
ui = Gem::MockGemUi.new "1\n"
|
ui = Gem::MockGemUi.new "1\n"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue