tap: support fast clone

Closes Homebrew/homebrew#37592.
Closes Homebrew/homebrew#38268.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-04-01 20:31:17 +08:00
parent 9daeef5d95
commit fa9371e58e
3 changed files with 11 additions and 4 deletions

View File

@ -20,7 +20,9 @@ module Homebrew
tapd = HOMEBREW_LIBRARY/"Taps/#{user.downcase}/homebrew-#{repo.downcase}"
return false if tapd.directory?
ohai "Tapping #{repouser}/#{repo}"
abort unless system "git", "clone", "https://github.com/#{repouser}/homebrew-#{repo}", tapd.to_s
args = %W[clone https://github.com/#{repouser}/homebrew-#{repo} #{tapd}]
args << "--depth=1" unless ARGV.include?("--full")
safe_system "git", *args
files = []
tapd.find_formula { |file| files << file }
@ -109,7 +111,7 @@ module Homebrew
end
end
def tap_args(tap_name=ARGV.first)
def tap_args(tap_name=ARGV.named.first)
tap_name =~ HOMEBREW_TAP_ARGS_REGEX
raise "Invalid tap name" unless $1 && $3
[$1, $3]

View File

@ -345,11 +345,13 @@ Note that these flags should only appear after a command.
* `switch` <name> <version>:
Symlink all of the specific <version> of <name>'s install to Homebrew prefix.
* `tap` [<tap>]:
* `tap` [--full] [<tap>]:
Tap a new formula repository from GitHub, or list existing taps.
<tap> is of the form <user>/<repo>, e.g. `brew tap homebrew/dupes`.
If `--full` is passed, a full clone will be used.
* `tap --repair`:
Ensure all tapped formulae are symlinked into Library/Formula and prune dead
formulae from Library/Formula.

View File

@ -369,12 +369,15 @@ Instantiate a Homebrew build environment\. Uses our years\-battle\-hardened Home
Symlink all of the specific \fIversion\fR of \fIname\fR\'s install to Homebrew prefix\.
.
.TP
\fBtap\fR [\fItap\fR]
\fBtap\fR [\-\-full] [\fItap\fR]
Tap a new formula repository from GitHub, or list existing taps\.
.
.IP
\fItap\fR is of the form \fIuser\fR/\fIrepo\fR, e\.g\. \fBbrew tap homebrew/dupes\fR\.
.
.IP
If \fB\-\-full\fR is passed, a full clone will be used\.
.
.TP
\fBtap \-\-repair\fR
Ensure all tapped formulae are symlinked into Library/Formula and prune dead formulae from Library/Formula\.