70 lines
2.5 KiB
Ruby
Raw Normal View History

2016-04-08 16:28:43 +02:00
#: * `tap`:
#: List all installed taps.
#:
#: * `tap` [`--full`] [`--force-auto-update`] <user>`/`<repo> [<URL>]:
2016-04-08 16:28:43 +02:00
#: Tap a formula repository.
#:
#: With <URL> unspecified, taps a formula repository from GitHub using HTTPS.
#: Since so many taps are hosted on GitHub, this command is a shortcut for
#: `brew tap` <user>`/`<repo> `https://github.com/`<user>`/homebrew-`<repo>.
2016-04-08 16:28:43 +02:00
#:
#: With <URL> specified, taps a formula repository from anywhere, using
#: any transport protocol that `git` handles. The one-argument form of `tap`
#: simplifies but also limits. This two-argument command makes no
#: 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.
#:
#: By default, the repository is cloned as a shallow copy (`--depth=1`), but
#: if `--full` is passed, a full clone will be used. To convert a shallow copy
#: to a full copy, you can retap passing `--full` without first untapping.
#:
#: By default, only taps hosted on GitHub are auto-updated (for performance
#: reasons). If `--force-auto-update` is passed, this tap will be auto-updated
#: even if it is not hosted on GitHub.
#:
2016-04-08 16:28:43 +02:00
#: `tap` is re-runnable and exits successfully if there's nothing to do.
#: However, retapping with a different <URL> will cause an exception, so first
#: `untap` if you need to modify the <URL>.
#:
#: * `tap` `--repair`:
#: Migrate tapped formulae from symlink-based to directory-based structure.
#:
#: * `tap` `--list-pinned`:
#: List all pinned taps.
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2012-03-02 20:28:54 +00:00
def tap
if ARGV.include? "--repair"
Tap.each(&:link_completions_and_manpages)
elsif ARGV.include? "--list-official"
odisabled("brew tap --list-official")
elsif ARGV.include? "--list-pinned"
2015-08-21 12:33:33 +08:00
puts Tap.select(&:pinned?).map(&:name)
elsif ARGV.named.empty?
puts Tap.names
2012-03-02 20:28:54 +00:00
else
tap = Tap.fetch(ARGV.named[0])
2015-11-10 18:33:57 +08:00
begin
tap.install clone_target: ARGV.named[1],
force_auto_update: force_auto_update?,
full_clone: full_clone?,
quiet: ARGV.quieter?
rescue TapRemoteMismatchError => e
odie e
rescue TapAlreadyTappedError, TapAlreadyUnshallowError # rubocop:disable Lint/HandleExceptions
2015-11-10 09:12:25 +00:00
end
2012-03-02 20:28:54 +00:00
end
end
def full_clone?
ARGV.include?("--full") || ARGV.homebrew_developer?
end
def force_auto_update?
# if no relevant flag is present, return nil, meaning "no change"
true if ARGV.include?("--force-auto-update")
end
2012-03-16 12:49:09 +00:00
end