brew info understands taps

Note I removed some of the code that changed the URL to be that of the github.user. Because this doesn't make any sense really. We want people to reference the commit history for whatever fork of homebrew they have checked out. So this is now what it does.
This commit is contained in:
Max Howell 2012-03-06 17:35:10 +00:00
parent 765ae96180
commit 6c0950999f

View File

@ -20,21 +20,30 @@ module Homebrew extend self
end end
end end
def github_info name def github_fork
formula_name = Formula.path(name).basename
user = 'mxcl'
branch = 'master'
if system "/usr/bin/which -s git" if system "/usr/bin/which -s git"
gh_user=`git config --global github.user 2>/dev/null`.chomp if `git remote -v` =~ %r{origin\s+(https?://|git@)github.com[:/](.+)/homebrew}
/^\*\s*(.*)/.match(`git --git-dir=#{HOMEBREW_REPOSITORY}/.git branch 2>/dev/null`) $2
unless $1.nil? || $1.empty? || $1.chomp == 'master' || gh_user.empty?
branch = $1.chomp
user = gh_user
end end
end end
end
"http://github.com/#{user}/homebrew/commits/#{branch}/Library/Formula/#{formula_name}" def github_info name
path = Formula.path(name).realpath
if path.to_s =~ %r{#{HOMEBREW_REPOSITORY}/Library/Taps/(\w+)-(\w+)/(.*)}
user = $1
repo = "homebrew-#$2"
path = $3
else
path.parent.cd do
user = github_fork
end
repo = "homebrew"
path = "Library/Formula/#{path.basename}"
end
"https://github.com/#{user}/#{repo}/commits/master/#{path}"
end end
def info_formula f def info_formula f
@ -68,16 +77,16 @@ module Homebrew extend self
puts "Not installed" puts "Not installed"
end end
history = github_info f.name
puts history if history
the_caveats = (f.caveats || "").strip the_caveats = (f.caveats || "").strip
unless the_caveats.empty? unless the_caveats.empty?
puts puts
ohai "Caveats"
puts f.caveats puts f.caveats
puts
end end
history = github_info f.name
puts history if history
rescue FormulaUnavailableError rescue FormulaUnavailableError
# check for DIY installation # check for DIY installation
d = HOMEBREW_PREFIX+name d = HOMEBREW_PREFIX+name