Merge pull request #11337 from cnnrmnn/no-shallow-taps

No shallow taps
This commit is contained in:
Mike McQuaid 2021-05-07 22:22:09 +01:00 committed by GitHub
commit 3eaa0d7752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 29 deletions

View File

@ -56,18 +56,23 @@ module Homebrew
elsif args.no_named? elsif args.no_named?
puts Tap.names puts Tap.names
else else
full_clone = if args.full? if args.full?
true opoo "`brew tap --full` is now a no-op!"
else # TODO: (3.2) Uncomment the following line and remove the `opoo` above
!args.shallow? # odeprecated "`brew tap --full`"
end end
odebug "Tapping as #{full_clone ? "full" : "shallow"} clone"
if args.shallow?
opoo "`brew tap --shallow` is now a no-op!"
# TODO: (3.2) Uncomment the following line and remove the `opoo` above
# odeprecated "`brew tap --shallow`"
end
tap = Tap.fetch(args.named.first) tap = Tap.fetch(args.named.first)
begin begin
tap.install clone_target: args.named.second, tap.install clone_target: args.named.second,
force_auto_update: force_auto_update?(args: args), force_auto_update: force_auto_update?(args: args),
quiet: args.quiet?, quiet: args.quiet?
full_clone: full_clone
rescue TapRemoteMismatchError => e rescue TapRemoteMismatchError => e
odie e odie e
rescue TapAlreadyTappedError rescue TapAlreadyTappedError

View File

@ -244,9 +244,8 @@ class Tap
# @param clone_target [String] If passed, it will be used as the clone remote. # @param clone_target [String] If passed, it will be used as the clone remote.
# @param force_auto_update [Boolean, nil] If present, whether to override the # @param force_auto_update [Boolean, nil] If present, whether to override the
# logic that skips non-GitHub repositories during auto-updates. # logic that skips non-GitHub repositories during auto-updates.
# @param full_clone [Boolean] If set as true, full clone will be used. If unset/nil, means "no change".
# @param quiet [Boolean] If set, suppress all output. # @param quiet [Boolean] If set, suppress all output.
def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil) def install(quiet: false, clone_target: nil, force_auto_update: nil)
require "descriptions" require "descriptions"
require "readall" require "readall"
@ -270,11 +269,13 @@ class Tap
if installed? if installed?
unless force_auto_update.nil? unless force_auto_update.nil?
config["forceautoupdate"] = force_auto_update config["forceautoupdate"] = force_auto_update
return if !full_clone || !shallow? return
end end
$stderr.ohai "Unshallowing #{name}" unless quiet $stderr.ohai "Unshallowing #{name}" if shallow? && !quiet
args = %w[fetch --unshallow] args = %w[fetch]
# Git throws an error when attempting to unshallow a full clone
args << "--unshallow" if shallow?
args << "-q" if quiet args << "-q" if quiet
path.cd { safe_system "git", *args } path.cd { safe_system "git", *args }
return return
@ -288,7 +289,6 @@ class Tap
# Override possible user configs like: # Override possible user configs like:
# git config --global clone.defaultRemoteName notorigin # git config --global clone.defaultRemoteName notorigin
args << "--origin=origin" args << "--origin=origin"
args << "--depth=1" unless full_clone
args << "-q" if quiet args << "-q" if quiet
begin begin
@ -736,14 +736,12 @@ class CoreTap < Tap
end end
# CoreTap never allows shallow clones (on request from GitHub). # CoreTap never allows shallow clones (on request from GitHub).
def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil) def install(quiet: false, clone_target: nil, force_auto_update: nil)
raise "Shallow clones are not supported for homebrew-core!" unless full_clone
remote = Homebrew::EnvConfig.core_git_remote remote = Homebrew::EnvConfig.core_git_remote
if remote != default_remote if remote != default_remote
$stderr.puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} for Homebrew/core Git remote URL." $stderr.puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} for Homebrew/core Git remote URL."
end end
super(full_clone: full_clone, quiet: quiet, clone_target: remote, force_auto_update: force_auto_update) super(quiet: quiet, clone_target: remote, force_auto_update: force_auto_update)
end end
# @private # @private

View File

@ -9,7 +9,7 @@ describe "brew tap" do
it "taps a given Tap", :integration_test do it "taps a given Tap", :integration_test do
path = setup_test_tap path = setup_test_tap
expect { brew "tap", "--force-auto-update", "--full", "homebrew/bar", path/".git" } expect { brew "tap", "--force-auto-update", "homebrew/bar", path/".git" }
.to output(/Tapped/).to_stderr .to output(/Tapped/).to_stderr
.and be_a_success .and be_a_success
end end

View File

@ -220,7 +220,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
system "git", "clone", "--shared", system_tap_path, tap.path system "git", "clone", "--shared", system_tap_path, tap.path
system "git", "-C", tap.path, "checkout", "master" system "git", "-C", tap.path, "checkout", "master"
else else
tap.install(full_clone: false, quiet: true) tap.install(quiet: true)
end end
end end
end end

View File

@ -1882,12 +1882,10 @@ _brew_tap() {
__brewcomp " __brewcomp "
--debug --debug
--force-auto-update --force-auto-update
--full
--help --help
--list-pinned --list-pinned
--quiet --quiet
--repair --repair
--shallow
--verbose --verbose
" "
return return

View File

@ -1266,12 +1266,10 @@ __fish_brew_complete_arg 'style; and not __fish_seen_argument -l formula -l form
__fish_brew_complete_cmd 'tap' 'Tap a formula repository' __fish_brew_complete_cmd 'tap' 'Tap a formula repository'
__fish_brew_complete_arg 'tap' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'tap' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'tap' -l force-auto-update -d 'Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)' __fish_brew_complete_arg 'tap' -l force-auto-update -d 'Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)'
__fish_brew_complete_arg 'tap' -l full -d 'Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones if `--shallow` was originally passed'
__fish_brew_complete_arg 'tap' -l help -d 'Show this message' __fish_brew_complete_arg 'tap' -l help -d 'Show this message'
__fish_brew_complete_arg 'tap' -l list-pinned -d 'List all pinned taps' __fish_brew_complete_arg 'tap' -l list-pinned -d 'List all pinned taps'
__fish_brew_complete_arg 'tap' -l quiet -d 'Make some output more quiet' __fish_brew_complete_arg 'tap' -l quiet -d 'Make some output more quiet'
__fish_brew_complete_arg 'tap' -l repair -d 'Migrate tapped formulae from symlink-based to directory-based structure' __fish_brew_complete_arg 'tap' -l repair -d 'Migrate tapped formulae from symlink-based to directory-based structure'
__fish_brew_complete_arg 'tap' -l shallow -d 'Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration'
__fish_brew_complete_arg 'tap' -l verbose -d 'Make some output more verbose' __fish_brew_complete_arg 'tap' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'tap' -a '(__fish_brew_suggest_taps_installed)' __fish_brew_complete_arg 'tap' -a '(__fish_brew_suggest_taps_installed)'

View File

@ -1557,12 +1557,10 @@ _brew_tap() {
_arguments \ _arguments \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'--force-auto-update[Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)]' \ '--force-auto-update[Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)]' \
'--full[Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones if `--shallow` was originally passed]' \
'--help[Show this message]' \ '--help[Show this message]' \
'--list-pinned[List all pinned taps]' \ '--list-pinned[List all pinned taps]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \
'--repair[Migrate tapped formulae from symlink-based to directory-based structure]' \ '--repair[Migrate tapped formulae from symlink-based to directory-based structure]' \
'--shallow[Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration]' \
'--verbose[Make some output more verbose]' \ '--verbose[Make some output more verbose]' \
- tap \ - tap \
'*::tap:__brew_any_tap' '*::tap:__brew_any_tap'

View File

@ -536,10 +536,6 @@ simplifies but also limits. This two-argument command makes no
assumptions, so taps can be cloned from places other than GitHub and assumptions, so taps can be cloned from places other than GitHub and
using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync.
* `--full`:
Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones if `--shallow` was originally passed.
* `--shallow`:
Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration.
* `--force-auto-update`: * `--force-auto-update`:
Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons). Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons).
* `--repair`: * `--repair`: