aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2009-11-25 19:57:47 -0800
committerMax Howell2009-12-12 16:24:15 +0000
commitd391f7c70e25646c3724307f4335d9b723e6a1d8 (patch)
tree39cb4ce88eab2e24700be8a8447350ef6b2e635d /Library
parent8443c9be7df0ef4bd63f9b46894876ce0433db56 (diff)
downloadbrew-d391f7c70e25646c3724307f4335d9b723e6a1d8.tar.bz2
--github improvements
* Only invoke git if --github was passed; speeds up brew info --all * Use current branch for --github instead of master.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brew.h.rb38
1 files changed, 27 insertions, 11 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index 7d5b00bf5..f06b0b206 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