From d391f7c70e25646c3724307f4335d9b723e6a1d8 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Wed, 25 Nov 2009 19:57:47 -0800 Subject: [PATCH] --github improvements * Only invoke git if --github was passed; speeds up brew info --all * Use current branch for --github instead of master. --- Library/Homebrew/brew.h.rb | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 7d5b00bf56..f06b0b2062 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -47,6 +47,9 @@ Mercurial can be install thusly: end end +DEFAULT_USER = 'mxcl' +DEFAULT_BRANCH = 'master' + def __make url, name require 'formula' @@ -152,25 +155,38 @@ ENV.libxml2 in your formula's install function. __make url, name end +def github_info name + formula_name = Formula.path(name).basename + user = '' + branch = '' + + if system "/usr/bin/which -s git" + user=`git config --global github.user`.chomp + all_branches = `git branch 2>/dev/null` + /^\*\s*(.*)/.match all_branches + branch = ($1 || '').chomp + end + + user = DEFAULT_USER if user.empty? + branch = DEFAULT_BRANCH if user.empty? + + history="http://github.com/#{user}/homebrew/commits/#{branch}/Library/Formula/#{formula_name}" + exec 'open', history +end def info name require 'formula' - user='' - user=`git config --global github.user`.chomp if system "/usr/bin/which -s git" - user='mxcl' if user.empty? - # FIXME it would be nice if we didn't assume the default branch is master - history="http://github.com/#{user}/homebrew/commits/master/Library/Formula/#{Formula.path(name).basename}" - - exec 'open', history if ARGV.flag? '--github' + if ARGV.flag? '--github' + github_info name + return + end f=Formula.factory name puts "#{f.name} #{f.version}" puts f.homepage - if not f.deps.empty? - puts "Depends on: #{f.deps.join(', ')}" - end + puts "Depends on: #{f.deps.join(', ')}" unless f.deps.empty? if f.prefix.parent.directory? kids=f.prefix.parent.children @@ -189,7 +205,7 @@ def info name puts end - puts history + puts history if history rescue FormulaUnavailableError # check for DIY installation