From 2acb4771fe9170a6c2368c3a15ef6652ad1632c5 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Thu, 9 Apr 2020 18:36:36 +1000 Subject: [PATCH 1/3] tap: permit creating shallow taps for CI --- Library/Homebrew/cmd/tap.rb | 5 ++++- Library/Homebrew/tap.rb | 2 +- docs/Manpage.md | 2 ++ manpages/brew.1 | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 91f873e679..d50320b46e 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -27,6 +27,8 @@ module Homebrew switch "--full", description: "Convert a shallow clone to a full clone without untapping. By default, taps are no "\ "longer cloned as shallow clones." + switch "--shallow", + description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration." switch "--force-auto-update", description: "Auto-update tap even if it is not hosted on GitHub. By default, only taps "\ "hosted on GitHub are auto-updated (for performance reasons)." @@ -55,7 +57,8 @@ module Homebrew begin tap.install clone_target: args.named.second, force_auto_update: force_auto_update?, - quiet: args.quiet? + quiet: args.quiet?, + full_clone: !args.shallow? rescue TapRemoteMismatchError => e odie e rescue TapAlreadyTappedError diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 8721bbe0e7..9894b4b47b 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -243,7 +243,7 @@ class Tap if installed? raise TapRemoteMismatchError.new(name, @remote, requested_remote) if clone_target && requested_remote != remote - raise TapAlreadyTappedError, name if force_auto_update.nil? + raise TapAlreadyTappedError, name if force_auto_update.nil? && !shallow? end # ensure git is installed diff --git a/docs/Manpage.md b/docs/Manpage.md index 4ee618eb7e..5bff0b9bc2 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -502,6 +502,8 @@ HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. * `--full`: Convert a shallow clone to a full clone without untapping. By default, taps are no longer cloned as shallow clones. +* `--shallow`: + Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration. * `--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). * `--repair`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 3fcc451a7f..1573d332ca 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -638,6 +638,10 @@ With \fIURL\fR specified, tap a formula repository from anywhere, using any tran Convert a shallow clone to a full clone without untapping\. By default, taps are no longer cloned as shallow clones\. . .TP +\fB\-\-shallow\fR +Fetch tap as a shallow clone rather than a full clone\. Useful for continuous integration\. +. +.TP \fB\-\-force\-auto\-update\fR Auto\-update tap even if it is not hosted on GitHub\. By default, only taps hosted on GitHub are auto\-updated (for performance reasons)\. . From 945fb11d51db237f26698080a42f8c0ad6703beb Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Sat, 11 Apr 2020 12:35:17 +1000 Subject: [PATCH 2/3] tap: default to --shallow on CI --- Library/Homebrew/cmd/tap.rb | 14 +++++++++++--- docs/Manpage.md | 2 +- manpages/brew.1 | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index d50320b46e..ffb69b3b07 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -25,8 +25,8 @@ module Homebrew using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. EOS switch "--full", - description: "Convert a shallow clone to a full clone without untapping. By default, taps are no "\ - "longer cloned as shallow clones." + description: "Convert a shallow clone to a full clone without untapping. Taps are only cloned as "\ + "shallow clones on continuous integration, or if `--shallow` was originally passed." switch "--shallow", description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration." switch "--force-auto-update", @@ -53,12 +53,20 @@ module Homebrew elsif args.no_named? puts Tap.names else + full_clone = if args.full? + true + elsif args.shallow?.nil? + !ENV["CI"] + else + !args.shallow? + end + odebug "Tapping as #{full_clone ? "full" : "shallow"} clone" tap = Tap.fetch(args.named.first) begin tap.install clone_target: args.named.second, force_auto_update: force_auto_update?, quiet: args.quiet?, - full_clone: !args.shallow? + full_clone: full_clone rescue TapRemoteMismatchError => e odie e rescue TapAlreadyTappedError diff --git a/docs/Manpage.md b/docs/Manpage.md index 5bff0b9bc2..fac878fc10 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -501,7 +501,7 @@ taps can be cloned from places other than GitHub and using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. * `--full`: - Convert a shallow clone to a full clone without untapping. By default, taps are no longer cloned as shallow clones. + Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones on continuous integration, or if `--shallow` was originally passed. * `--shallow`: Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration. * `--force-auto-update`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 1573d332ca..4f57726721 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -635,7 +635,7 @@ With \fIURL\fR specified, tap a formula repository from anywhere, using any tran . .TP \fB\-\-full\fR -Convert a shallow clone to a full clone without untapping\. By default, taps are no longer cloned as shallow clones\. +Convert a shallow clone to a full clone without untapping\. Taps are only cloned as shallow clones on continuous integration, or if \fB\-\-shallow\fR was originally passed\. . .TP \fB\-\-shallow\fR From bec303de86f9cef21a79ebea55da59dfa57fbdbb Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Sat, 11 Apr 2020 22:41:04 +1000 Subject: [PATCH 3/3] tap: update shallowing logic Co-Authored-By: Mike McQuaid --- Library/Homebrew/cmd/tap.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index ffb69b3b07..addde2b4af 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -55,8 +55,8 @@ module Homebrew else full_clone = if args.full? true - elsif args.shallow?.nil? - !ENV["CI"] + elsif !args.shallow? + ENV["CI"].blank? else !args.shallow? end