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') 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') 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') 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 From 9bee9ca5757d1c5f720787737fed6a534a620d72 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 15 Oct 2017 02:28:32 +0200 Subject: Use “squiggly” heredocs. --- Library/Homebrew/dev-cmd/audit.rb | 16 ++++++++-------- Library/Homebrew/dev-cmd/bottle.rb | 4 ++-- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 14 ++++++-------- Library/Homebrew/dev-cmd/create.rb | 4 ++-- Library/Homebrew/dev-cmd/edit.rb | 2 +- Library/Homebrew/dev-cmd/mirror.rb | 2 +- Library/Homebrew/dev-cmd/tap-new.rb | 4 ++-- Library/Homebrew/dev-cmd/update-test.rb | 2 +- 8 files changed, 23 insertions(+), 25 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index a9d27afa9..ec26eb9cd 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -368,7 +368,7 @@ class FormulaAuditor if valid_versioned_aliases.empty? if formula.tap - problem <<-EOS.undent + problem <<~EOS Formula has other versions so create a versioned alias: cd #{formula.tap.alias_dir} ln -s #{formula.path.to_s.gsub(formula.tap.path, "..")} #{alias_name} @@ -379,7 +379,7 @@ class FormulaAuditor end unless invalid_versioned_aliases.empty? - problem <<-EOS.undent + problem <<~EOS Formula has invalid versioned aliases: #{invalid_versioned_aliases.join("\n ")} EOS @@ -476,7 +476,7 @@ class FormulaAuditor when "gfortran" problem "Use `depends_on :fortran` instead of `depends_on 'gfortran'`" when "ruby" - problem <<-EOS.undent + problem <<~EOS Don't use "ruby" as a dependency. If this formula requires a minimum Ruby version not provided by the system you should use the RubyRequirement: @@ -484,7 +484,7 @@ class FormulaAuditor where "1.8" is the minimum version of Ruby required. EOS when "open-mpi", "mpich" - problem <<-EOS.undent + problem <<~EOS There are multiple conflicting ways to install MPI. Use an MPIRequirement: depends_on :mpi => [] Where is a comma delimited list that can include: @@ -492,7 +492,7 @@ class FormulaAuditor EOS when *BUILD_TIME_DEPS next if dep.build? || dep.run? - problem <<-EOS.undent + problem <<~EOS #{dep} dependency should be depends_on "#{dep}" => :build Or if it is indeed a runtime dependency @@ -541,7 +541,7 @@ class FormulaAuditor first_word = reason.split[0] if reason =~ /\A[A-Z]/ && !reason.start_with?(*whitelist) - problem <<-EOS.undent + problem <<~EOS '#{first_word}' from the keg_only reason should be '#{first_word.downcase}'. EOS end @@ -1010,7 +1010,7 @@ class FormulaAuditor return unless formula.tap&.official? return unless formula.tap.tap_migrations.key?(formula.name) - problem <<-EOS.undent + problem <<~EOS #{formula.name} seems to be listed in tap_migrations.json! Please remove #{formula.name} from present tap & tap_migrations.json before submitting it to Homebrew/homebrew-#{formula.tap.repo}. @@ -1021,7 +1021,7 @@ class FormulaAuditor return unless formula.prefix.directory? return unless Keg.new(formula.prefix).empty_installation? - problem <<-EOS.undent + problem <<~EOS The installation seems to be empty. Please ensure the prefix is set correctly and expected files are installed. The prefix configure/make argument may be case-sensitive. diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index fb862c773..a54211f5c 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -324,7 +324,7 @@ module Homebrew "#{key}: old: #{old_value}, new: #{value}" end - odie <<-EOS.undent + odie <<~EOS --keep-old was passed but there are changes in: #{mismatches.join("\n")} EOS @@ -428,7 +428,7 @@ module Homebrew end unless mismatches.empty? - odie <<-EOS.undent + odie <<~EOS --keep-old was passed but there are changes in: #{mismatches.join("\n")} EOS diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 87d8274cc..fe7e6be3d 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -91,7 +91,7 @@ module Homebrew pull_requests = fetch_pull_requests(formula) return unless pull_requests return if pull_requests.empty? - duplicates_message = <<-EOS.undent + duplicates_message = <<~EOS These open pull requests may be duplicates: #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} EOS @@ -101,7 +101,7 @@ module Homebrew elsif !ARGV.force? && ARGV.flag?("--quiet") odie error_message elsif !ARGV.force? - odie <<-EOS.undent + odie <<~EOS #{duplicates_message.chomp} #{error_message} EOS @@ -247,13 +247,13 @@ module Homebrew if new_formula_version < old_formula_version formula.path.atomic_write(backup_file) unless ARGV.dry_run? - odie <<-EOS.undent + odie <<~EOS You probably need to bump this formula manually since changing the version from #{old_formula_version} to #{new_formula_version} would be a downgrade. EOS elsif new_formula_version == old_formula_version formula.path.atomic_write(backup_file) unless ARGV.dry_run? - odie <<-EOS.undent + odie <<~EOS You probably need to bump this formula manually since the new version and old version are both #{new_formula_version}. EOS @@ -312,17 +312,15 @@ module Homebrew remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1] if remote.to_s.empty? odie "cannot get remote from 'hub'!" if remote.to_s.empty? safe_system "git", "push", "--set-upstream", remote, "#{branch}:#{branch}" - pr_message = <<-EOS.undent + pr_message = <<~EOS #{formula.name} #{new_formula_version}#{devel_message} Created with `brew bump-formula-pr`. EOS user_message = ARGV.value("message") if user_message - pr_message += <<-EOS.undent - + pr_message += <<~EOS --- - #{user_message} EOS end diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index e423842ba..e5481b532 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -71,7 +71,7 @@ module Homebrew if Formula.aliases.include? fc.name realname = Formulary.canonical_name(fc.name) - raise <<-EOS.undent + raise <<~EOS The formula #{realname} is already aliased to #{fc.name} Please check that you are not creating a duplicate. To force creation use --force. @@ -165,7 +165,7 @@ class FormulaCreator path.write ERB.new(template, nil, ">").result(binding) end - def template; <<-EOS.undent + def template; <<~EOS # Documentation: https://docs.brew.sh/Formula-Cookbook.html # http://www.rubydoc.info/github/Homebrew/brew/master/Formula # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index b1e485fe2..0039b4cce 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -11,7 +11,7 @@ module Homebrew def edit unless (HOMEBREW_REPOSITORY/".git").directory? - raise <<-EOS.undent + raise <<~EOS Changes will be lost! The first time you `brew update', all local changes will be lost, you should thus `brew update' before you `brew edit'! diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index 6445bc34c..bf19ee3c5 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -20,7 +20,7 @@ module Homebrew package_url = "#{bintray_repo_url}/#{bintray_package}" unless system "curl", "--silent", "--fail", "--output", "/dev/null", package_url - package_blob = <<-EOS.undent + package_blob = <<~EOS {"name": "#{bintray_package}", "public_download_numbers": true, "public_stats": true} diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 964ba2f5d..1c3bf20eb 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -24,7 +24,7 @@ module Homebrew (tap.path/"Formula").mkpath - readme = <<-EOS.undent + readme = <<~EOS # #{titleized_user} #{titleized_repo} ## How do I install these formulae? @@ -43,7 +43,7 @@ module Homebrew EOS write_path(tap, "README.md", readme) - travis = <<-EOS.undent + travis = <<~EOS language: ruby os: osx env: OSX=10.12 diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index 1f1cdbeed..ee189ad5e 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -88,7 +88,7 @@ module Homebrew safe_system "brew", "update", "--verbose" actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp if start_commit != end_commit && start_commit == actual_end_commit - raise <<-EOS.undent + raise <<~EOS brew update didn't update #{branch}! Start commit: #{start_commit} Expected end commit: #{end_commit} -- cgit v1.2.3