mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
brew-pull: add support for pulling from taps
This commit is contained in:
parent
d3ba9723b2
commit
04bf4e5f89
@ -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?
|
||||
|
Loading…
x
Reference in New Issue
Block a user