Skip to content

Commit

Permalink
Defend against unusual Homebrew setups
Browse files Browse the repository at this point in the history
To aid in Tap transition.  Require Homebrew 0.9.5, rescue
`rename_tags_dir_if_necessary` (`respond_to?` won't work there
because `rename_tags_dir_if_necessary` is a private method.

References: Homebrew#4192, @Jackiebo in Homebrew#4096
  • Loading branch information
rolandwalker authored and gaishimo committed May 16, 2014
1 parent 0af142d commit 3a2f0b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Cask; end

# transitional, for set_up_taps (see below)
require 'cmd/update'
require 'rubygems'

require 'cask/artifact'
require 'cask/audit'
Expand Down Expand Up @@ -65,8 +66,22 @@ def self.init
def self.set_up_taps
odebug 'Initializing Taps'

return true if Cask.default_tap.match(%r{test[^/]*\Z})

# transitional: help with Homebrew's move of Tap dirs, Apr 2014
Homebrew.send(:rename_taps_dir_if_necessary)
minimum_homebrew_version = '0.9.5'
unless Gem::Version.new(HOMEBREW_VERSION) >= Gem::Version.new(minimum_homebrew_version)
raise CaskError.new <<-EOS.undent
Minimum Homebrew version '#{minimum_homebrew_version}' required.
(Homebrew version #{HOMEBREW_VERSION} was detected.)
Try running "brew update".
EOS
end
begin
Homebrew.send(:rename_taps_dir_if_necessary)
rescue StandardError
opoo %q{Trouble with automatic Tap migration. You may need to run "brew update && brew upgrade brew-cask"}
end

# transitional: help with our own move to new GitHub project, May 2014
legacy_user = 'phinze'
Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
# our baby
require 'cask'

# look for casks in testcasks by default
# Look for casks in testcasks by default. It is elsewhere required that
# the string "test" appear in the directory name.
Cask.default_tap = 'caskroom/homebrew-testcasks'

# our own testy caskroom
Expand Down

0 comments on commit 3a2f0b2

Please sign in to comment.