From 04bf4e5f8977e4e7792f39da87cdf2e67f8ca03c Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 6 Apr 2012 09:47:43 -0500 Subject: [PATCH] brew-pull: add support for pulling from taps --- Library/Contributions/cmds/brew-pull.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Library/Contributions/cmds/brew-pull.rb b/Library/Contributions/cmds/brew-pull.rb index f7e2516d53..f17ecdbc78 100755 --- a/Library/Contributions/cmds/brew-pull.rb +++ b/Library/Contributions/cmds/brew-pull.rb @@ -3,18 +3,21 @@ require 'utils' +def tap arg + match = arg.match(%r[homebrew-(\w+)/]) + match[1] if match +end + if ARGV.empty? onoe 'This command requires at least one argument containing a URL or pull request number' end -Dir.chdir HOMEBREW_REPOSITORY - ARGV.named.each do|arg| if arg.to_i > 0 url = 'https://github.com/mxcl/homebrew/pull/' + arg else # This regex should work, if it's too precise, feel free to fix it. - url_match = arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/(\d+)|commit\/\w{4,40})' + url_match = arg.match 'https:\/\/github.com\/\w+\/homebrew(-\w+)?\/(pull\/(\d+)|commit\/\w{4,40})' unless url_match ohai 'Ignoring URL:', "Not a GitHub pull request or commit: #{arg}" next @@ -23,6 +26,12 @@ ARGV.named.each do|arg| url = url_match[0] end + if tap url + Dir.chdir HOMEBREW_REPOSITORY/"Library/Taps/homebrew-#{tap url}" + else + Dir.chdir HOMEBREW_REPOSITORY + end + # GitHub provides commits'/pull-requests' raw patches using this URL. url += '.patch' @@ -65,7 +74,7 @@ ARGV.named.each do|arg| `git diff #{revision}.. --name-status`.each_line do |line| status, filename = line.split # Don't try and do anything to removed files. - if (status == 'A' or status == 'M') and filename.include? '/Formula/' + if (status == 'A' or status == 'M') and filename.include? '/Formula/' or tap url formula = File.basename(filename, '.rb') ohai "Installing #{formula}" # Not sure if this is the best way to install?