Skip to content
Snippets Groups Projects
Unverified Commit 243e7037 authored by Mike McQuaid's avatar Mike McQuaid
Browse files

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.
parent 2d21fa09
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment