pull: pull from PR then from BrewTestBot.

This allows making e.g. `Closes #X` point to the correct commit to reduce confusion and allows `--bump` to function correctly.
This commit is contained in:
Mike McQuaid 2014-11-01 10:13:32 +00:00
parent a01a3bd594
commit 992f40e119

View File

@ -10,6 +10,37 @@ module Homebrew
match[1].downcase if match match[1].downcase if match
end end
def pull_url url
# GitHub provides commits/pull-requests raw patches using this URL.
url += '.patch'
patchpath = HOMEBREW_CACHE + File.basename(url)
curl url, '-o', patchpath
ohai 'Applying patch'
patch_args = []
# Normally we don't want whitespace errors, but squashing them can break
# patches so an option is provided to skip this step.
if ARGV.include? '--ignore-whitespace' or ARGV.include? '--clean'
patch_args << '--whitespace=nowarn'
else
patch_args << '--whitespace=fix'
end
# Fall back to three-way merge if patch does not apply cleanly
patch_args << "-3"
patch_args << patchpath
begin
safe_system 'git', 'am', *patch_args
rescue ErrorDuringExecution
system 'git', 'am', '--abort'
odie 'Patch failed to apply: aborted.'
ensure
patchpath.unlink
end
end
def pull def pull
if ARGV.empty? if ARGV.empty?
onoe 'This command requires at least one argument containing a URL or pull request number' onoe 'This command requires at least one argument containing a URL or pull request number'
@ -34,6 +65,10 @@ module Homebrew
issue = url_match[3] issue = url_match[3]
end end
if ARGV.include?("--bottle") && issue.nil?
raise "No pull request detected!"
end
if tap_name = tap(url) if tap_name = tap(url)
user = url_match[1].downcase user = url_match[1].downcase
tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}" tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}"
@ -43,47 +78,13 @@ module Homebrew
Dir.chdir HOMEBREW_REPOSITORY Dir.chdir HOMEBREW_REPOSITORY
end end
if ARGV.include? '--bottle'
if issue
url = "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
else
raise "No pull request detected!"
end
end
# GitHub provides commits'/pull-requests' raw patches using this URL.
url += '.patch'
# The cache directory seems like a good place to put patches. # The cache directory seems like a good place to put patches.
HOMEBREW_CACHE.mkpath HOMEBREW_CACHE.mkpath
patchpath = HOMEBREW_CACHE + File.basename(url)
curl url, '-o', patchpath
# Store current revision # Store current revision
revision = `git rev-parse --short HEAD`.strip revision = `git rev-parse --short HEAD`.strip
ohai 'Applying patch' pull_url url
patch_args = []
# Normally we don't want whitespace errors, but squashing them can break
# patches so an option is provided to skip this step.
if ARGV.include? '--ignore-whitespace' or ARGV.include? '--clean'
patch_args << '--whitespace=nowarn'
else
patch_args << '--whitespace=fix'
end
# Fall back to three-way merge if patch does not apply cleanly
patch_args << "-3"
patch_args << patchpath
begin
safe_system 'git', 'am', *patch_args
rescue ErrorDuringExecution
system 'git', 'am', '--abort'
odie 'Patch failed to apply: aborted.'
ensure
patchpath.unlink
end
changed_formulae = [] changed_formulae = []
@ -107,7 +108,7 @@ module Homebrew
end end
end end
unless ARGV.include?('--bottle') unless ARGV.include? '--bottle'
changed_formulae.each do |f| changed_formulae.each do |f|
next unless f.bottle next unless f.bottle
opoo "#{f.name} has a bottle: do you need to update it with --bottle?" opoo "#{f.name} has a bottle: do you need to update it with --bottle?"
@ -133,6 +134,10 @@ module Homebrew
end end
end end
if ARGV.include? "--bottle"
pull_url "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
end
ohai 'Patch changed:' ohai 'Patch changed:'
safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD" safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD"