From 243e703700fd0c06aea982e5b2b7f45b6dedcabb Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 2 Feb 2020 16:36:01 +0100 Subject: [PATCH] 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. --- Library/Homebrew/cmd/tap.rb | 3 ++- Library/Homebrew/exceptions.rb | 12 ------------ Library/Homebrew/tap.rb | 15 +++++++-------- Library/Homebrew/test/tap_spec.rb | 7 ------- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 656dc20768..279dde75c6 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -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 diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 55fa41db68..3c81060a06 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -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 diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index b5c8550263..6e6824f98a 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -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 diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb index 2a6f1d6dea..4a14ee081d 100644 --- a/Library/Homebrew/test/tap_spec.rb +++ b/Library/Homebrew/test/tap_spec.rb @@ -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