pull: use tap object
Fix the regression introduced by Homebrew/homebrew#46735.
This commit is contained in:
parent
c347d40f1b
commit
3cc101ec5e
@ -6,13 +6,6 @@ require "formula"
|
|||||||
require "cmd/tap"
|
require "cmd/tap"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
HOMEBREW_PULL_API_REGEX = %r{https://api\.github\.com/repos/([\w-]+)/homebrew(-[\w-]+)?/pulls/(\d+)}
|
|
||||||
|
|
||||||
def tap(arg)
|
|
||||||
match = arg.match(%r{homebrew-([\w-]+)/})
|
|
||||||
match[1].downcase if match
|
|
||||||
end
|
|
||||||
|
|
||||||
def pull_url(url)
|
def pull_url(url)
|
||||||
# GitHub provides commits/pull-requests raw patches using this URL.
|
# GitHub provides commits/pull-requests raw patches using this URL.
|
||||||
url += ".patch"
|
url += ".patch"
|
||||||
@ -61,37 +54,31 @@ module Homebrew
|
|||||||
|
|
||||||
ARGV.named.each do |arg|
|
ARGV.named.each do |arg|
|
||||||
if arg.to_i > 0
|
if arg.to_i > 0
|
||||||
url = "https://github.com/Homebrew/homebrew/pull/#{arg}"
|
|
||||||
issue = arg
|
issue = arg
|
||||||
|
url = "https://github.com/Homebrew/homebrew/pull/#{arg}"
|
||||||
|
tap = CoreFormulaRepository.instance
|
||||||
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/})
|
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/})
|
||||||
_, testing_job = *testing_match
|
_, testing_job = *testing_match
|
||||||
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
|
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
|
||||||
|
tap = CoreFormulaRepository.instance
|
||||||
odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")
|
odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")
|
||||||
|
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
||||||
|
_, user, repo, issue = *api_match
|
||||||
|
url = "https://github.com/#{user}/homebrew#{repo}/pull/#{issue}"
|
||||||
|
tap = Tap.fetch(user, "homebrew#{repo}")
|
||||||
|
elsif (url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX)
|
||||||
|
url, user, repo, issue = *url_match
|
||||||
|
tap = Tap.fetch(user, "homebrew#{repo}")
|
||||||
else
|
else
|
||||||
if (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
odie "Not a GitHub pull request or commit: #{arg}"
|
||||||
_, user, tap, pull = *api_match
|
|
||||||
arg = "https://github.com/#{user}/homebrew#{tap}/pull/#{pull}"
|
|
||||||
end
|
|
||||||
|
|
||||||
url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX
|
|
||||||
odie "Not a GitHub pull request or commit: #{arg}" unless url_match
|
|
||||||
|
|
||||||
url = url_match[0]
|
|
||||||
issue = url_match[3]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if !testing_job && ARGV.include?("--bottle") && issue.nil?
|
if !testing_job && ARGV.include?("--bottle") && issue.nil?
|
||||||
raise "No pull request detected!"
|
raise "No pull request detected!"
|
||||||
end
|
end
|
||||||
|
|
||||||
if !testing_job && tap_name = tap(url)
|
tap.install unless tap.installed?
|
||||||
user = url_match[1].downcase
|
Dir.chdir tap.path
|
||||||
tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}"
|
|
||||||
safe_system "brew", "tap", "#{user}/#{tap_name}" unless tap_dir.exist?
|
|
||||||
Dir.chdir tap_dir
|
|
||||||
else
|
|
||||||
Dir.chdir HOMEBREW_REPOSITORY
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -108,15 +95,9 @@ module Homebrew
|
|||||||
|
|
||||||
changed_formulae = []
|
changed_formulae = []
|
||||||
|
|
||||||
if tap_dir
|
|
||||||
formula_dir = %w[Formula HomebrewFormula].find { |d| tap_dir.join(d).directory? } || ""
|
|
||||||
else
|
|
||||||
formula_dir = "Library/Formula"
|
|
||||||
end
|
|
||||||
|
|
||||||
Utils.popen_read(
|
Utils.popen_read(
|
||||||
"git", "diff-tree", "-r", "--name-only",
|
"git", "diff-tree", "-r", "--name-only",
|
||||||
"--diff-filter=AM", revision, "HEAD", "--", formula_dir
|
"--diff-filter=AM", revision, "HEAD", "--", tap.formula_dir.to_s
|
||||||
).each_line do |line|
|
).each_line do |line|
|
||||||
name = File.basename(line.chomp, ".rb")
|
name = File.basename(line.chomp, ".rb")
|
||||||
|
|
||||||
@ -170,10 +151,10 @@ module Homebrew
|
|||||||
url
|
url
|
||||||
else
|
else
|
||||||
bottle_branch = "pull-bottle-#{issue}"
|
bottle_branch = "pull-bottle-#{issue}"
|
||||||
if tap_name
|
if tap.core_formula_repository?
|
||||||
"https://github.com/BrewTestBot/homebrew-#{tap_name}/compare/homebrew:master...pr-#{issue}"
|
|
||||||
else
|
|
||||||
"https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
|
"https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}"
|
||||||
|
else
|
||||||
|
"https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url
|
curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url
|
||||||
@ -190,7 +171,7 @@ module Homebrew
|
|||||||
bintray_key = ENV["BINTRAY_KEY"]
|
bintray_key = ENV["BINTRAY_KEY"]
|
||||||
|
|
||||||
if bintray_user && bintray_key
|
if bintray_user && bintray_key
|
||||||
repo = Bintray.repository(tap_name)
|
repo = Bintray.repository(tap)
|
||||||
changed_formulae.each do |f|
|
changed_formulae.each do |f|
|
||||||
next if f.bottle_unneeded? || f.bottle_disabled?
|
next if f.bottle_unneeded? || f.bottle_disabled?
|
||||||
ohai "Publishing on Bintray:"
|
ohai "Publishing on Bintray:"
|
||||||
|
|||||||
@ -41,6 +41,7 @@ module Homebrew
|
|||||||
alias_method :failed?, :failed
|
alias_method :failed?, :failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
HOMEBREW_PULL_API_REGEX = %r{https://api\.github\.com/repos/([\w-]+)/homebrew(-[\w-]+)?/pulls/(\d+)}
|
||||||
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/homebrew(-[\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})]
|
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/homebrew(-[\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})]
|
||||||
|
|
||||||
require "compat" unless ARGV.include?("--no-compat") || ENV["HOMEBREW_NO_COMPAT"]
|
require "compat" unless ARGV.include?("--no-compat") || ENV["HOMEBREW_NO_COMPAT"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user