tap: default to full clones.

This makes `Tap` consistent with what the installer is doing.

Generally shallow clones get slower and slower (and more and more
pointless) the more they are fetched so don't make sense for our
use-case.

Keep the option around anyway because it's useful for integration tests.
This commit is contained in:
Mike McQuaid 2020-02-02 16:36:01 +01:00
parent 2d21fa0928
commit 243e703700
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 9 additions and 28 deletions

View File

@ -60,7 +60,8 @@ module Homebrew
quiet: args.quieter?
rescue TapRemoteMismatchError => e
odie e
rescue TapAlreadyTappedError, TapAlreadyUnshallowError # rubocop:disable Lint/SuppressedException
rescue TapAlreadyTappedError
nil
end
end
end

View File

@ -258,18 +258,6 @@ class TapAlreadyTappedError < RuntimeError
end
end
class TapAlreadyUnshallowError < RuntimeError
attr_reader :name
def initialize(name)
@name = name
super <<~EOS
Tap #{name} already a full clone.
EOS
end
end
class TapPinStatusError < RuntimeError
attr_reader :name, :pinned

View File

@ -233,7 +233,7 @@ class Tap
def install(options = {})
require "descriptions"
full_clone = options.fetch(:full_clone, false)
full_clone = options.fetch(:full_clone, true)
quiet = options.fetch(:quiet, false)
requested_remote = options[:clone_target] || default_remote
# if :force_auto_update is unset, use nil, meaning "no change"
@ -245,9 +245,12 @@ class Tap
odie "#{name} was moved. Tap homebrew/cask-#{repo} instead."
end
if installed? && force_auto_update.nil?
raise TapAlreadyTappedError, name unless full_clone
raise TapAlreadyUnshallowError, name unless shallow?
if installed?
if options[:clone_target] && requested_remote != remote
raise TapRemoteMismatchError.new(name, @remote, requested_remote)
end
raise TapAlreadyTappedError, name if force_auto_update.nil?
end
# ensure git is installed
@ -259,10 +262,6 @@ class Tap
return if !full_clone || !shallow?
end
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

View File

@ -207,7 +207,6 @@ describe Tap do
it "raises an error when the remote doesn't match" do
setup_git_repo
already_tapped_tap = described_class.new("Homebrew", "foo")
touch subject.path/".git/shallow"
expect(already_tapped_tap).to be_installed
wrong_remote = "#{subject.remote}-oops"
expect {
@ -215,12 +214,6 @@ describe Tap do
}.to raise_error(TapRemoteMismatchError)
end
it "raises an error when the Tap is already unshallow" do
setup_git_repo
already_tapped_tap = described_class.new("Homebrew", "foo")
expect { already_tapped_tap.install full_clone: true }.to raise_error(TapAlreadyUnshallowError)
end
describe "force_auto_update" do
before do
setup_git_repo