brew-pull: Allow pull request numbers as arguments
If an integer is passed to `brew-pull`, such as `brew pull 6600`, it will be
interpreted as a pull request number. This has the same effect as the more
verbose command line:
brew pull https://github.com/mxcl/homebrew/pull/6600
This commit is contained in:
parent
f52955ec98
commit
6d6da0c0ef
@ -9,11 +9,14 @@ if ARGV.include? '--install'
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
onoe 'This command requires at least one URL argument'
|
onoe 'This command requires at least one argument containing a URL or pull request number'
|
||||||
end
|
end
|
||||||
|
|
||||||
HOMEBREW_REPOSITORY.cd do
|
HOMEBREW_REPOSITORY.cd do
|
||||||
ARGV.each do|arg|
|
ARGV.each do|arg|
|
||||||
|
if arg.to_i > 0
|
||||||
|
url = 'https://github.com/mxcl/homebrew/pull/' + arg + '.patch'
|
||||||
|
else
|
||||||
# This regex should work, if it's too precise, feel free to fix it.
|
# This regex should work, if it's too precise, feel free to fix it.
|
||||||
urlmatch = arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/(\d+)|commit\/\w{4,40})'
|
urlmatch = arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/(\d+)|commit\/\w{4,40})'
|
||||||
if !urlmatch
|
if !urlmatch
|
||||||
@ -23,6 +26,7 @@ HOMEBREW_REPOSITORY.cd do
|
|||||||
|
|
||||||
# GitHub provides commits'/pull-requests' raw patches using this URL.
|
# GitHub provides commits'/pull-requests' raw patches using this URL.
|
||||||
url = urlmatch[0] + '.patch'
|
url = urlmatch[0] + '.patch'
|
||||||
|
end
|
||||||
|
|
||||||
# The cache directory seems like a good place to put patches.
|
# The cache directory seems like a good place to put patches.
|
||||||
patchpath = (HOMEBREW_CACHE+File.basename(url))
|
patchpath = (HOMEBREW_CACHE+File.basename(url))
|
||||||
@ -35,7 +39,7 @@ HOMEBREW_REPOSITORY.cd do
|
|||||||
ohai 'Applying patch'
|
ohai 'Applying patch'
|
||||||
safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath
|
safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath
|
||||||
|
|
||||||
issue = urlmatch[2]
|
issue = arg.to_i > 0 ? arg.to_i : urlmatch[2]
|
||||||
if issue
|
if issue
|
||||||
ohai "Patch closes issue ##{issue}"
|
ohai "Patch closes issue ##{issue}"
|
||||||
message = `git log HEAD^.. --format=%B`
|
message = `git log HEAD^.. --format=%B`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user