From 76021db6029b2a1787ade83127c0431baa4b38fe Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Fri, 6 Oct 2017 16:04:28 -0700 Subject: pull: Add --bintray-org Infer the name of the Bintray organization if it's not provided. --- Library/Homebrew/dev-cmd/pull.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Library/Homebrew/dev-cmd/pull.rb') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index aa3c9a9d7..130e9ed5d 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -1,4 +1,4 @@ -#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] [`--warn-on-publish-failure`] []: +#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] [`--warn-on-publish-failure`] [`--bintray-org=`] []: #: #: Gets a patch from a GitHub commit or pull request and applies it to Homebrew. #: Optionally, installs the formulae changed by the patch. @@ -41,6 +41,9 @@ #: #: If `--warn-on-publish-failure` was passed, do not exit if there's a #: failure publishing bottles on Bintray. +#: +#: If `--bintray-org=` is passed, publish at the given Bintray +#: organisation. require "net/http" require "net/https" @@ -257,7 +260,7 @@ module Homebrew str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) end - def publish_changed_formula_bottles(_tap, changed_formulae_names) + def publish_changed_formula_bottles(tap, changed_formulae_names) if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"] raise "Need to load formulae to publish them!" end @@ -268,7 +271,8 @@ module Homebrew changed_formulae_names.each do |name| f = Formula[name] next if f.bottle_unneeded? || f.bottle_disabled? - next unless publish_bottle_file_on_bintray(f, bintray_creds) + bintray_org = ARGV.value("bintray-org") || tap.user.downcase + next unless publish_bottle_file_on_bintray(f, bintray_org, bintray_creds) published << f.full_name end else @@ -420,7 +424,7 @@ module Homebrew end # Publishes the current bottle files for a given formula to Bintray - def publish_bottle_file_on_bintray(f, creds) + def publish_bottle_file_on_bintray(f, bintray_org, creds) repo = Utils::Bottles::Bintray.repository(f.tap) package = Utils::Bottles::Bintray.package(f.name) info = FormulaInfoFromJson.lookup(f.name) @@ -437,7 +441,7 @@ module Homebrew "--user", "#{creds[:user]}:#{creds[:key]}", "--request", "POST", "--header", "Content-Type: application/json", "--data", '{"publish_wait_for_secs": 0}', - "https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish" + "https://api.bintray.com/content/#{bintray_org}/#{repo}/#{package}/#{version}/publish" true rescue => e raise unless ARGV.include?("--warn-on-publish-failure") -- cgit v1.2.3 From 9cd4fff051fa64d2c72ea55c97b819b3db9d1df9 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Fri, 6 Oct 2017 16:17:00 -0700 Subject: pull: Add --test-bot-user Infer the name of the test-bot GitHub user if it is not provided. --- Library/Homebrew/dev-cmd/pull.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/dev-cmd/pull.rb') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 130e9ed5d..0e3b37e3f 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -1,4 +1,4 @@ -#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] [`--warn-on-publish-failure`] [`--bintray-org=`] []: +#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] [`--warn-on-publish-failure`] [`--bintray-org=`] [`--test-bot-user=`] []: #: #: Gets a patch from a GitHub commit or pull request and applies it to Homebrew. #: Optionally, installs the formulae changed by the patch. @@ -44,6 +44,9 @@ #: #: If `--bintray-org=` is passed, publish at the given Bintray #: organisation. +#: +#: If `--test-bot-user=` is passed, pull the bottle block +#: commit from the specified user on GitHub. require "net/http" require "net/https" @@ -228,7 +231,7 @@ module Homebrew url else bottle_branch = "pull-bottle-#{issue}" - "https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}" + "https://github.com/#{test_bot_user user}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}" end curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url @@ -256,6 +259,13 @@ module Homebrew verify_bintray_published(bintray_published_formulae) end + def test_bot_user(user) + test_bot = ARGV.value "test-bot-user" + return test_bot if test_bot + return "BrewTestBot" if user.casecmp("homebrew").zero? + "#{user.capitalize}TestBot" + end + def force_utf8!(str) str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) end -- cgit v1.2.3 From 3ee3b78fbda48821e878feeafc313a9391c5729c Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Tue, 17 Oct 2017 17:08:11 -0700 Subject: pull: Move test_bot_user to a new module GitHub Address the style issue: C: Module has too many lines. [364/360] --- Library/Homebrew/dev-cmd/pull.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Library/Homebrew/dev-cmd/pull.rb') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 0e3b37e3f..79b9da9eb 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -58,6 +58,18 @@ require "tap" require "version" require "pkg_version" +module GitHub + module_function + + # Return the corresponding test-bot user name for the given GitHub organization. + def test_bot_user(user) + test_bot = ARGV.value "test-bot-user" + return test_bot if test_bot + return "BrewTestBot" if user.casecmp("homebrew").zero? + "#{user.capitalize}TestBot" + end +end + module Homebrew module_function @@ -231,7 +243,7 @@ module Homebrew url else bottle_branch = "pull-bottle-#{issue}" - "https://github.com/#{test_bot_user user}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}" + "https://github.com/#{GitHub.test_bot_user user}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}" end curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url @@ -259,13 +271,6 @@ module Homebrew verify_bintray_published(bintray_published_formulae) end - def test_bot_user(user) - test_bot = ARGV.value "test-bot-user" - return test_bot if test_bot - return "BrewTestBot" if user.casecmp("homebrew").zero? - "#{user.capitalize}TestBot" - end - def force_utf8!(str) str.force_encoding("UTF-8") if str.respond_to?(:force_encoding) end -- cgit v1.2.3