From 33fa3bacf6fa93e8f9f8a60d875eb45dc7b76462 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 3 Jul 2015 10:59:53 +0100 Subject: [PATCH] pull: support Jenkins "Homebrew Testing" jobs. --- Library/Homebrew/cmd/pull.rb | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/pull.rb b/Library/Homebrew/cmd/pull.rb index c321941b8a..4458dfe1a4 100644 --- a/Library/Homebrew/cmd/pull.rb +++ b/Library/Homebrew/cmd/pull.rb @@ -59,8 +59,12 @@ module Homebrew ARGV.named.each do |arg| if arg.to_i > 0 - url = 'https://github.com/Homebrew/homebrew/pull/' + arg + url = "https://github.com/Homebrew/homebrew/pull/#{arg}" issue = arg + elsif (testing_match = arg.match %r{brew.sh/job/Homebrew%20Testing/(\d+)/}) + _, testing_job = *testing_match + url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}" + odie "Testing URLs require `--bottle`!" unless ARGV.include?('--bottle') else if (api_match = arg.match HOMEBREW_PULL_API_REGEX) _, user, tap, pull = *api_match @@ -74,11 +78,11 @@ module Homebrew issue = url_match[3] end - if ARGV.include?("--bottle") && issue.nil? + if !testing_job && ARGV.include?("--bottle") && issue.nil? raise "No pull request detected!" end - if tap_name = tap(url) + if !testing_job && tap_name = tap(url) user = url_match[1].downcase tap_dir = HOMEBREW_REPOSITORY/"Library/Taps/#{user}/homebrew-#{tap_name}" safe_system "brew", "tap", "#{user}/#{tap_name}" unless tap_dir.exist? @@ -150,14 +154,20 @@ module Homebrew end if ARGV.include? "--bottle" - bottle_commit_url = if tap_name - "https://github.com/BrewTestBot/homebrew-#{tap_name}/compare/homebrew:master...pr-#{issue}" + + bottle_commit_url = if testing_job + bottle_branch = "testing-bottle-#{testing_job}" + url else - "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}" + bottle_branch = "pull-bottle-#{issue}" + if tap_name + "https://github.com/BrewTestBot/homebrew-#{tap_name}/compare/homebrew:master...pr-#{issue}" + else + "https://github.com/BrewTestBot/homebrew/compare/homebrew:master...pr-#{issue}" + end end curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url - bottle_branch = "pull-bottle-#{issue}" safe_system "git", "checkout", "-B", bottle_branch, revision pull_url bottle_commit_url safe_system "git", "rebase", branch