aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2016-10-06 12:56:39 +0200
committerGitHub2016-10-06 12:56:39 +0200
commit7e70ebd4f188e59172decc3a74aa61fbb4b58655 (patch)
tree3fa3b3f3212ce4308222bc8b45b6ebcc7f2a90b8 /Library
parent6f070641b92d8ccaccb8c15713eb4b9c110c1ebd (diff)
parent0f7d1b137f55264366c772105e5026253906d896 (diff)
downloadbrew-7e70ebd4f188e59172decc3a74aa61fbb4b58655.tar.bz2
Merge pull request #1207 from reitermarkus/cask-already-installed-warning
Change `A Cask for #{token} is already installed.` message.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/install.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/exceptions.rb51
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb7
-rw-r--r--Library/Homebrew/cask/test/cask/cli/install_test.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/installer_test.rb2
5 files changed, 39 insertions, 25 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb
index d7575344d..996de8d1b 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/install.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb
@@ -27,7 +27,7 @@ module Hbc
rescue CaskAlreadyInstalledError => e
opoo e.message
count += 1
- rescue CaskAutoUpdatesError => e
+ rescue CaskAlreadyInstalledAutoUpdatesError => e
opoo e.message
count += 1
rescue CaskUnavailableError => e
diff --git a/Library/Homebrew/cask/lib/hbc/exceptions.rb b/Library/Homebrew/cask/lib/hbc/exceptions.rb
index f77106d92..8c9481eec 100644
--- a/Library/Homebrew/cask/lib/hbc/exceptions.rb
+++ b/Library/Homebrew/cask/lib/hbc/exceptions.rb
@@ -29,13 +29,30 @@ module Hbc
class CaskAlreadyInstalledError < AbstractCaskErrorWithToken
def to_s
- %Q{A Cask for #{token} is already installed. Add the "--force" option to force re-install.}
+ s = <<-EOS.undent
+ A Cask for #{token} is already installed.
+ EOS
+
+ s.concat("\n").concat(reinstall_message)
+ end
+
+ private
+
+ def reinstall_message
+ <<-EOS.undent
+ To re-install #{token}, run:
+ brew cask uninstall --force #{token} && brew cask install #{token}
+ EOS
end
end
- class CaskAutoUpdatesError < AbstractCaskErrorWithToken
+ class CaskAlreadyInstalledAutoUpdatesError < CaskAlreadyInstalledError
def to_s
- %Q{A Cask for #{token} is already installed and using auto-updates. Add the "--force" option to force re-install.}
+ s = <<-EOS.undent
+ A Cask for #{token} is already installed and using auto-updates.
+ EOS
+
+ s.concat("\n").concat(reinstall_message)
end
end
@@ -48,21 +65,19 @@ module Hbc
end
def to_s
- <<-EOS
- Command failed to execute!
-
- ==> Failed command:
- #{@cmd}
-
- ==> Standard Output of failed command:
- #{@stdout}
-
- ==> Standard Error of failed command:
- #{@stderr}
-
- ==> Exit status of failed command:
- #{@status.inspect}
- EOS
+ s = "Command failed to execute!\n"
+ s.concat("\n")
+ s.concat("==> Failed command:\n")
+ s.concat(@cmd).concat("\n")
+ s.concat("\n")
+ s.concat("==> Standard Output of failed command:\n")
+ s.concat(@stdout).concat("\n")
+ s.concat("\n")
+ s.concat("==> Standard Error of failed command:\n")
+ s.concat(@stderr).concat("\n")
+ s.concat("\n")
+ s.concat("==> Exit status of failed command:\n")
+ s.concat(@status.inspect).concat("\n")
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 4d29acb75..9575aa181 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -58,12 +58,11 @@ module Hbc
def install
odebug "Hbc::Installer.install"
- if @cask.installed? && @cask.auto_updates && !force
- raise CaskAutoUpdatesError, @cask
+ if @cask.installed? && !force
+ raise CaskAlreadyInstalledAutoUpdatesError, @cask if @cask.auto_updates
+ raise CaskAlreadyInstalledError, @cask
end
- raise CaskAlreadyInstalledError, @cask if @cask.installed? && !force
-
print_caveats
begin
diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/test/cask/cli/install_test.rb
index 2d09846b7..138c497fb 100644
--- a/Library/Homebrew/cask/test/cask/cli/install_test.rb
+++ b/Library/Homebrew/cask/test/cask/cli/install_test.rb
@@ -29,7 +29,7 @@ describe Hbc::CLI::Install do
TestHelper.must_output(self, lambda {
Hbc::CLI::Install.run("local-transmission", "")
- }, %r{Warning: A Cask for local-transmission is already installed. Add the "--force" option to force re-install.})
+ }, %r{Warning: A Cask for local-transmission is already installed.})
end
it "allows double install with --force" do
diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb
index 2275c3080..64a0e9b87 100644
--- a/Library/Homebrew/cask/test/cask/installer_test.rb
+++ b/Library/Homebrew/cask/test/cask/installer_test.rb
@@ -272,7 +272,7 @@ describe Hbc::Installer do
lambda {
installer.install
- }.must_raise(Hbc::CaskAutoUpdatesError)
+ }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError)
end
it "allows already-installed Casks which auto-update to be installed if force is provided" do