aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/aspell-dictionaries.rb5
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb201
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb13
-rw-r--r--Library/Homebrew/dev-cmd/bump-formula-pr.rb14
-rw-r--r--Library/Homebrew/dev-cmd/create.rb4
-rw-r--r--Library/Homebrew/dev-cmd/edit.rb2
-rw-r--r--Library/Homebrew/dev-cmd/man.rb9
-rw-r--r--Library/Homebrew/dev-cmd/mirror.rb2
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb44
-rw-r--r--Library/Homebrew/dev-cmd/tap-new.rb4
-rw-r--r--Library/Homebrew/dev-cmd/test.rb2
-rw-r--r--Library/Homebrew/dev-cmd/update-test.rb2
12 files changed, 74 insertions, 228 deletions
diff --git a/Library/Homebrew/dev-cmd/aspell-dictionaries.rb b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
index 955e41b01..ab0e66d2b 100644
--- a/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
+++ b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
@@ -27,13 +27,12 @@ module Homebrew
end
end
- languages.inject([]) do |resources, (lang, path)|
+ languages.each do |lang, path|
r = Resource.new(lang)
r.owner = Formulary.factory("aspell")
r.url "#{dict_url}/#{path}"
r.mirror "#{dict_mirror}/#{path}"
- resources << r
- end.each(&:fetch).each do |r|
+ r.fetch
puts <<-EOS
option "with-lang-#{r.name}", "Install #{r.name} dictionary"
resource "#{r.name}" do
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 16ae7cba1..bfe4dbc00 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -53,7 +53,7 @@ module Homebrew
module_function
def audit
- Homebrew.inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D"
+ inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D"
Homebrew.auditing = true
formula_count = 0
@@ -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
@@ -387,8 +387,10 @@ class FormulaAuditor
end
end
- # core aliases + tap alias names + tap alias full name
- @@aliases ||= Formula.aliases + Formula.tap_aliases
+ def self.aliases
+ # core aliases + tap alias names + tap alias full name
+ @aliases ||= Formula.aliases + Formula.tap_aliases
+ end
def audit_formula_name
return unless @strict
@@ -442,7 +444,7 @@ class FormulaAuditor
problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
end
- if @@aliases.include?(dep.name) &&
+ if self.class.aliases.include?(dep.name) &&
(dep_f.core_formula? || !dep_f.versioned_formula?)
problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
end
@@ -453,16 +455,16 @@ class FormulaAuditor
problem "Dependency '#{dep.name}' may be unnecessary as it is provided by macOS; try to build this formula without it."
end
- dep.options.reject do |opt|
- next true if dep_f.option_defined?(opt)
- dep_f.requirements.detect do |r|
+ dep.options.each do |opt|
+ next if dep_f.option_defined?(opt)
+ next if dep_f.requirements.detect do |r|
if r.recommended?
opt.name == "with-#{r.name}"
elsif r.optional?
opt.name == "without-#{r.name}"
end
end
- end.each do |opt|
+
problem "Dependency #{dep} does not define option #{opt.name.inspect}"
end
@@ -474,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:
@@ -482,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 => [<lang list>]
Where <lang list> is a comma delimited list that can include:
@@ -490,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
@@ -539,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
@@ -590,7 +592,8 @@ class FormulaAuditor
return if metadata.nil?
problem "GitHub fork (not canonical repository)" if metadata["fork"]
- if (metadata["forks_count"] < 20) && (metadata["subscribers_count"] < 20) &&
+ if formula&.tap&.core_tap? &&
+ (metadata["forks_count"] < 20) && (metadata["subscribers_count"] < 20) &&
(metadata["stargazers_count"] < 50)
problem "GitHub repository not notable enough (<20 forks, <20 watchers and <50 stars)"
end
@@ -817,164 +820,12 @@ class FormulaAuditor
problem "\"(#{Regexp.last_match(1)}...#{Regexp.last_match(2)})\" should be \"(#{Regexp.last_match(3).downcase}+...)\""
end
- if line =~ /((man)\s*\+\s*(['"])(man[1-8])(['"]))/
- problem "\"#{Regexp.last_match(1)}\" should be \"#{Regexp.last_match(4)}\""
- end
-
- # Prefer formula path shortcuts in strings
- if line =~ %r[(\#\{prefix\}/(bin|include|libexec|lib|sbin|share|Frameworks))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2).downcase}}\""
- end
-
- if line =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
- end
-
- if line =~ %r[((\#\{share\}/(man)))[/'"]]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
- end
-
- if line =~ %r[(\#\{prefix\}/share/(info|man))]
- problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2)}}\""
- end
-
- if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
- problem "#{Regexp.last_match(2)} modules should be vendored rather than use deprecated `depends_on \"#{Regexp.last_match(1)}\" => :#{Regexp.last_match(2)}#{Regexp.last_match(3)}`"
- end
-
- if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+(.*)/
- dep = Regexp.last_match(1)
- Regexp.last_match(2).split(" ").map do |o|
- break if ["if", "unless"].include?(o)
- next unless o =~ /^\[?['"](.*)['"]/
- problem "Dependency #{dep} should not use option #{Regexp.last_match(1)}"
- end
- end
-
- if line =~ /if\s+ARGV\.include\?\s+'--(HEAD|devel)'/
- problem "Use \"if build.#{Regexp.last_match(1).downcase}?\" instead"
- end
-
problem "Use separate make calls" if line.include?("make && make")
- problem "Use spaces instead of tabs for indentation" if line =~ /^[ ]*\t/
-
- if line.include?("ENV.java_cache")
- problem "In-formula ENV.java_cache usage has been deprecated & should be removed."
- end
-
- # Avoid hard-coding compilers
- if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?(gcc|llvm-gcc|clang)['" ]}
- problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
- end
-
- if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?((g|llvm-g|clang)\+\+)['" ]}
- problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
- end
-
- if line =~ /system\s+['"](env|export)(\s+|['"])/
- problem "Use ENV instead of invoking '#{Regexp.last_match(1)}' to modify the environment"
- end
-
- if line =~ /version == ['"]HEAD['"]/
- problem "Use 'build.head?' instead of inspecting 'version'"
- end
-
- if line =~ /build\.include\?[\s\(]+['"]\-\-(.*)['"]/
- problem "Reference '#{Regexp.last_match(1)}' without dashes"
- end
-
- if line =~ /build\.include\?[\s\(]+['"]with(out)?-(.*)['"]/
- problem "Use build.with#{Regexp.last_match(1)}? \"#{Regexp.last_match(2)}\" instead of build.include? 'with#{Regexp.last_match(1)}-#{Regexp.last_match(2)}'"
- end
-
- if line =~ /build\.with\?[\s\(]+['"]-?-?with-(.*)['"]/
- problem "Don't duplicate 'with': Use `build.with? \"#{Regexp.last_match(1)}\"` to check for \"--with-#{Regexp.last_match(1)}\""
- end
-
- if line =~ /build\.without\?[\s\(]+['"]-?-?without-(.*)['"]/
- problem "Don't duplicate 'without': Use `build.without? \"#{Regexp.last_match(1)}\"` to check for \"--without-#{Regexp.last_match(1)}\""
- end
-
- if line =~ /unless build\.with\?(.*)/
- problem "Use if build.without?#{Regexp.last_match(1)} instead of unless build.with?#{Regexp.last_match(1)}"
- end
-
- if line =~ /unless build\.without\?(.*)/
- problem "Use if build.with?#{Regexp.last_match(1)} instead of unless build.without?#{Regexp.last_match(1)}"
- end
-
- if line =~ /(not\s|!)\s*build\.with?\?/
- problem "Don't negate 'build.with?': use 'build.without?'"
- end
-
- if line =~ /(not\s|!)\s*build\.without?\?/
- problem "Don't negate 'build.without?': use 'build.with?'"
- end
-
- if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/
- problem "Use build instead of ARGV to check options"
- end
-
- if line.include?("MACOS_VERSION")
- problem "Use MacOS.version instead of MACOS_VERSION"
- end
-
- if line.include?("MACOS_FULL_VERSION")
- problem "Use MacOS.full_version instead of MACOS_FULL_VERSION"
- end
-
- cats = %w[leopard snow_leopard lion mountain_lion].join("|")
- if line =~ /MacOS\.(?:#{cats})\?/
- problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead"
- end
-
- if line =~ /depends_on [A-Z][\w:]+\.new$/
- problem "`depends_on` can take requirement classes instead of instances"
- end
-
- if line =~ /^def (\w+).*$/
- problem "Define method #{Regexp.last_match(1).inspect} in the class body, not at the top-level"
- end
-
- if line.include?("ENV.fortran") && !formula.requirements.map(&:class).include?(FortranRequirement)
- problem "Use `depends_on :fortran` instead of `ENV.fortran`"
- end
-
if line =~ /JAVA_HOME/i && !formula.requirements.map(&:class).include?(JavaRequirement)
problem "Use `depends_on :java` to set JAVA_HOME"
end
- if line =~ /depends_on :(.+) (if.+|unless.+)$/
- conditional_dep_problems(Regexp.last_match(1).to_sym, Regexp.last_match(2), $&)
- end
-
- if line =~ /depends_on ['"](.+)['"] (if.+|unless.+)$/
- conditional_dep_problems(Regexp.last_match(1), Regexp.last_match(2), $&)
- end
-
- if line =~ /(Dir\[("[^\*{},]+")\])/
- problem "#{Regexp.last_match(1)} is unnecessary; just use #{Regexp.last_match(2)}"
- end
-
- if line =~ /system (["'](#{FILEUTILS_METHODS})["' ])/o
- system = Regexp.last_match(1)
- method = Regexp.last_match(2)
- problem "Use the `#{method}` Ruby method instead of `system #{system}`"
- end
-
- if line =~ /assert [^!]+\.include?/
- problem "Use `assert_match` instead of `assert ...include?`"
- end
-
- if line =~ /(assert File\.exist\?|assert \(.*\)\.exist\?)/
- problem "Use `assert_predicate <path_to_file>, :exist?` instead of `#{Regexp.last_match(1)}`"
- end
-
- if line =~ /assert !File\.exist\?/
- problem "Use `refute_predicate <path_to_file>, :exist?` instead of `assert !File.exist?`"
- end
-
return unless @strict
problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/
@@ -1003,7 +854,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}.
@@ -1014,25 +865,13 @@ 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.
EOS
end
- def conditional_dep_problems(dep, condition, line)
- quoted_dep = quote_dep(dep)
- dep = Regexp.escape(dep.to_s)
-
- case condition
- when /if build\.include\? ['"]with-#{dep}['"]$/, /if build\.with\? ['"]#{dep}['"]$/
- problem %Q(Replace #{line.inspect} with "depends_on #{quoted_dep} => :optional")
- when /unless build\.include\? ['"]without-#{dep}['"]$/, /unless build\.without\? ['"]#{dep}['"]$/
- problem %Q(Replace #{line.inspect} with "depends_on #{quoted_dep} => :recommended")
- end
- end
-
def quote_dep(dep)
dep.is_a?(Symbol) ? dep.inspect : "'#{dep}'"
end
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 8dfd0d12c..a54211f5c 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -75,7 +75,7 @@ module Homebrew
@put_filenames ||= []
- return if @put_filenames.include? filename
+ return if @put_filenames.include?(filename)
puts Formatter.error(filename.to_s)
@put_filenames << filename
@@ -84,8 +84,7 @@ module Homebrew
result = false
keg.each_unique_file_matching(string) do |file|
- # skip document file.
- next if Metafiles::EXTENSIONS.include? file.extname
+ next if Metafiles::EXTENSIONS.include?(file.extname) # Skip document files.
linked_libraries = Keg.file_linked_libraries(file, string)
result ||= !linked_libraries.empty?
@@ -156,9 +155,7 @@ module Homebrew
return ofail "Formula not installed or up-to-date: #{f.full_name}"
end
- tap = f.tap
-
- unless tap
+ unless tap = f.tap
unless ARGV.include?("--force-core-tap")
return ofail "Formula not from core or any taps: #{f.full_name}"
end
@@ -327,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
@@ -431,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/man.rb b/Library/Homebrew/dev-cmd/man.rb
index 472bb7c2b..b2bb3c8c3 100644
--- a/Library/Homebrew/dev-cmd/man.rb
+++ b/Library/Homebrew/dev-cmd/man.rb
@@ -48,12 +48,9 @@ module Homebrew
def path_glob_commands(glob)
Pathname.glob(glob)
.sort_by { |source_file| sort_key_for_path(source_file) }
- .map do |source_file|
- source_file.read.lines
- .grep(/^#:/)
- .map { |line| line.slice(2..-1) }
- .join
- end.reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") }
+ .map(&:read).map(&:lines)
+ .map { |lines| lines.grep(/^#:/).map { |line| line.slice(2..-1) }.join }
+ .reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") }
end
def build_man_page
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/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index cd0d6fbd0..7746e4db3 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`] <patch-source> [<patch-source>]:
+#: * `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] [`--warn-on-publish-failure`] [`--bintray-org=`<bintray-org>] [`--test-bot-user=`<test-bot-user>] <patch-source> [<patch-source>]:
#:
#: 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,12 @@
#:
#: If `--warn-on-publish-failure` was passed, do not exit if there's a
#: failure publishing bottles on Bintray.
+#:
+#: If `--bintray-org=`<bintray-org> is passed, publish at the given Bintray
+#: organisation.
+#:
+#: If `--test-bot-user=`<test-bot-user> is passed, pull the bottle block
+#: commit from the specified user on GitHub.
require "net/http"
require "net/https"
@@ -52,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
@@ -69,11 +87,8 @@ module Homebrew
tap = nil
ARGV.named.each do |arg|
- if arg.to_i.positive?
- issue = arg
- url = "https://github.com/Homebrew/homebrew-core/pull/#{arg}"
- tap = CoreTap.instance
- elsif (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/})
+ arg = "#{CoreTap.instance.default_remote}/pull/#{arg}" if arg.to_i.positive?
+ if (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/})
tap = ARGV.value("tap")
tap = if tap&.start_with?("homebrew/")
Tap.fetch("homebrew", tap.strip_prefix("homebrew/"))
@@ -154,8 +169,8 @@ module Homebrew
begin
f = Formula[name]
- # Make sure we catch syntax errors.
- rescue Exception
+ rescue Exception # rubocop:disable Lint/RescueException
+ # Make sure we catch syntax errors.
next
end
@@ -225,7 +240,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/#{GitHub.test_bot_user user}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}"
end
curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url
@@ -257,7 +272,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 +283,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 +436,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 +453,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")
@@ -560,7 +576,7 @@ module Homebrew
req = Net::HTTP::Head.new bottle_info.url
req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY
res = http.request req
- break if res.is_a?(Net::HTTPSuccess)
+ break if res.is_a?(Net::HTTPSuccess) || res.code == "302"
unless res.is_a?(Net::HTTPClientError)
raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
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/test.rb b/Library/Homebrew/dev-cmd/test.rb
index ab2b0edb0..6622a8c25 100644
--- a/Library/Homebrew/dev-cmd/test.rb
+++ b/Library/Homebrew/dev-cmd/test.rb
@@ -84,7 +84,7 @@ module Homebrew
rescue ::Test::Unit::AssertionFailedError => e
ofail "#{f.full_name}: failed"
puts e.message
- rescue Exception => e
+ rescue Exception => e # rubocop:disable Lint/RescueException
ofail "#{f.full_name}: failed"
puts e, e.backtrace
ensure
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}