Tap: allow enumerate non-git taps

Also add a `Tap#git?` method to indicate whether the tap is a git
repository.

Closes Homebrew/homebrew#42264.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-07-30 16:51:00 +08:00
parent 8c7b629149
commit a9b9c5ade7
2 changed files with 8 additions and 5 deletions

View File

@ -27,7 +27,7 @@ module Homebrew
# this procedure will be removed in the future if it seems unnecessasry # this procedure will be removed in the future if it seems unnecessasry
rename_taps_dir_if_necessary rename_taps_dir_if_necessary
Tap.each do |tap| Tap.select(&:git?).each do |tap|
tap.path.cd do tap.path.cd do
updater = Updater.new(tap.path) updater = Updater.new(tap.path)

View File

@ -37,7 +37,7 @@ class Tap
# e.g. `https://github.com/user/homebrew-repo` # e.g. `https://github.com/user/homebrew-repo`
def remote def remote
@remote ||= if installed? @remote ||= if installed?
if (@path/".git").exist? if git?
@path.cd do @path.cd do
Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp
end end
@ -49,6 +49,11 @@ class Tap
end end
end end
# True if this {Tap} is a git repository.
def git?
(@path/".git").exist?
end
def to_s def to_s
name name
end end
@ -117,12 +122,10 @@ class Tap
TAP_DIRECTORY.subdirs.each do |user| TAP_DIRECTORY.subdirs.each do |user|
user.subdirs.each do |repo| user.subdirs.each do |repo|
if (repo/".git").directory?
yield new(user.basename.to_s, repo.basename.to_s.sub("homebrew-", "")) yield new(user.basename.to_s, repo.basename.to_s.sub("homebrew-", ""))
end end
end end
end end
end
# an array of all installed {Tap} names. # an array of all installed {Tap} names.
def self.names def self.names