94 lines
3.0 KiB
Diff
94 lines
3.0 KiB
Diff
From 6a07398a3aac0793d1a62f6f4778d90baf86ab7e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
|
Date: Mon, 19 Nov 2012 14:41:06 +0100
|
|
Subject: [PATCH] RubyGems uninstaller upstream fixes.
|
|
|
|
---
|
|
lib/rubygems/uninstaller.rb | 35 +++++++++++++++++++++++------------
|
|
test/rubygems/test_gem_uninstaller.rb | 2 +-
|
|
2 files changed, 24 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
|
|
index cc32ea4..c0e8b4b 100644
|
|
--- a/lib/rubygems/uninstaller.rb
|
|
+++ b/lib/rubygems/uninstaller.rb
|
|
@@ -51,15 +51,14 @@ class Gem::Uninstaller
|
|
@bin_dir = options[:bin_dir]
|
|
@format_executable = options[:format_executable]
|
|
|
|
+ if options[:force]
|
|
+ @force_all = true
|
|
+ @force_ignore = true
|
|
+ end
|
|
+
|
|
# only add user directory if install_dir is not set
|
|
@user_install = false
|
|
@user_install = options[:user_install] unless options[:install_dir]
|
|
-
|
|
- if @user_install then
|
|
- Gem.use_paths Gem.user_dir, @gem_home
|
|
- else
|
|
- Gem.use_paths @gem_home
|
|
- end
|
|
end
|
|
|
|
##
|
|
@@ -69,10 +68,24 @@ class Gem::Uninstaller
|
|
def uninstall
|
|
list = Gem::Specification.find_all_by_name(@gem, @version)
|
|
|
|
+ list, other_repo_specs = list.partition do |spec|
|
|
+ @gem_home == spec.base_dir or
|
|
+ (@user_install and spec.base_dir == Gem.user_dir)
|
|
+ end
|
|
+
|
|
if list.empty? then
|
|
- raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
|
|
+ raise Gem::InstallError, "gem #{@gem.inspect} is not installed" if
|
|
+ other_repo_specs.empty?
|
|
+
|
|
+ other_repos = other_repo_specs.map { |spec| spec.base_dir }.uniq
|
|
+
|
|
+ message = ["#{@gem} is not installed in GEM_HOME, try:"]
|
|
+ message.concat other_repos.map { |repo|
|
|
+ "\tgem uninstall -i #{repo} #{@gem}"
|
|
+ }
|
|
|
|
- elsif list.size > 1 and @force_all then
|
|
+ raise Gem::InstallError, message.join("\n")
|
|
+ elsif @force_all then
|
|
remove_all list
|
|
|
|
elsif list.size > 1 then
|
|
@@ -250,12 +263,10 @@ class Gem::Uninstaller
|
|
msg << "\t#{spec.full_name}"
|
|
|
|
spec.dependent_gems.each do |dep_spec, dep, satlist|
|
|
- msg <<
|
|
- ("#{dep_spec.name}-#{dep_spec.version} depends on " +
|
|
- "[#{dep.name} (#{dep.requirement})]")
|
|
+ msg << "#{dep_spec.name}-#{dep_spec.version} depends on #{dep}"
|
|
end
|
|
|
|
- msg << 'If you remove this gems, one or more dependencies will not be met.'
|
|
+ msg << 'If you remove this gem, one or more dependencies will not be met.'
|
|
msg << 'Continue with Uninstall?'
|
|
return ask_yes_no(msg.join("\n"), true)
|
|
end
|
|
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
|
|
index a65b992..1cd186f 100644
|
|
--- a/test/rubygems/test_gem_uninstaller.rb
|
|
+++ b/test/rubygems/test_gem_uninstaller.rb
|
|
@@ -225,7 +225,7 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
|
|
|
uninstaller = Gem::Uninstaller.new('a')
|
|
|
|
- use_ui Gem::MockGemUi.new("2\n") do
|
|
+ use_ui Gem::MockGemUi.new("2\ny\n") do
|
|
uninstaller.uninstall
|
|
end
|
|
|
|
--
|
|
1.8.0
|
|
|