diff options
| author | Xu Cheng | 2016-04-19 15:18:54 +0800 |
|---|---|---|
| committer | Xu Cheng | 2016-04-19 16:29:29 +0800 |
| commit | 71b6e0aa18215cb956dceb13f0381da1131734c0 (patch) | |
| tree | 91d40da39c3befc4a92c638ca356fb5a9f383f6f /Library | |
| parent | 9b79f45e94805426c6bde47528063e5e505e2abd (diff) | |
| download | brew-71b6e0aa18215cb956dceb13f0381da1131734c0.tar.bz2 | |
Tap#install: better TapRemoteMismatchError check
* remote check requires `git` installed.
* Do not perform check if user does not passing remote explicitly.
Fixes #108
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/tap.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_tap.rb | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 042f1af52..52e6136b6 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -188,7 +188,6 @@ class Tap requested_remote = options[:clone_target] || "https://github.com/#{user}/homebrew-#{repo}" if installed? - raise TapRemoteMismatchError.new(name, @remote, requested_remote) unless remote == requested_remote raise TapAlreadyTappedError, name unless full_clone raise TapAlreadyUnshallowError, name unless shallow? end @@ -197,6 +196,10 @@ class Tap Utils.ensure_git_installed! if installed? + if options[:clone_target] && requested_remote != remote + raise TapRemoteMismatchError.new(name, @remote, requested_remote) + end + ohai "Unshallowing #{name}" unless quiet args = %W[fetch --unshallow] args << "-q" if quiet diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index a6b81dc95..94500babb 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -181,9 +181,10 @@ class TapTest < Homebrew::TestCase def test_install_tap_remote_mismatch_error setup_git_repo already_tapped_tap = Tap.new("Homebrew", "foo") + touch @tap.path/".git/shallow" assert_equal true, already_tapped_tap.installed? wrong_remote = "#{@tap.remote}-oops" - assert_raises(TapRemoteMismatchError) { already_tapped_tap.install :clone_target => wrong_remote } + assert_raises(TapRemoteMismatchError) { already_tapped_tap.install :clone_target => wrong_remote, :full_clone => true } end def test_install_tap_already_unshallow_error |
