From affd9055c2aaaf3535ed1cb778b65a4bee5ef0e2 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sun, 30 Jul 2017 20:14:59 +0530 Subject: audit: Port classname and template comments audit rules from line_problems method to rubocop --- Library/Homebrew/dev-cmd/audit.rb | 25 ------------------------- 1 file changed, 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 1f07fa89e..323b37170 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -809,28 +809,6 @@ class FormulaAuditor end def line_problems(line, _lineno) - if line =~ /<(Formula|AmazonWebServicesFormula|ScriptFileFormula|GithubGistFormula)/ - problem "Use a space in class inheritance: class Foo < #{Regexp.last_match(1)}" - end - - # Commented-out cmake support from default template - problem "Commented cmake call found" if line.include?('# system "cmake') - - # Comments from default template - [ - "# PLEASE REMOVE", - "# Documentation:", - "# if this fails, try separate make/make install steps", - "# The URL of the archive", - "## Naming --", - "# if your formula requires any X11/XQuartz components", - "# if your formula fails when building in parallel", - "# Remove unrecognized options if warned by configure", - ].each do |comment| - next unless line.include?(comment) - problem "Please remove default template comments" - end - # FileUtils is included in Formula # encfs modifies a file with this name, so check for some leading characters if line =~ %r{[^'"/]FileUtils\.(\w+)} @@ -891,9 +869,6 @@ class FormulaAuditor end end - # Commented-out depends_on - problem "Commented-out dep #{Regexp.last_match(1)}" if line =~ /#\s*depends_on\s+(.+)\s*$/ - if line =~ /if\s+ARGV\.include\?\s+'--(HEAD|devel)'/ problem "Use \"if build.#{Regexp.last_match(1).downcase}?\" instead" end -- cgit v1.2.3 From 7614d2cc8be065c33f4e4e893ccd1f0995a05401 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Mon, 31 Jul 2017 14:30:37 +0530 Subject: audit: Port FileUtils, inreplace audit rules in audit_lines to rubocop --- Library/Homebrew/dev-cmd/audit.rb | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 323b37170..cd5528cf5 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -809,17 +809,6 @@ class FormulaAuditor end def line_problems(line, _lineno) - # FileUtils is included in Formula - # encfs modifies a file with this name, so check for some leading characters - if line =~ %r{[^'"/]FileUtils\.(\w+)} - problem "Don't need 'FileUtils.' before #{Regexp.last_match(1)}." - end - - # Check for long inreplace block vars - if line =~ /inreplace .* do \|(.{2,})\|/ - problem "\"inreplace do |s|\" is preferred over \"|#{Regexp.last_match(1)}|\"." - end - # Check for string interpolation of single values. if line =~ /(system|inreplace|gsub!|change_make_var!).*[ ,]"#\{([\w.]+)\}"/ problem "Don't need to interpolate \"#{Regexp.last_match(2)}\" with #{Regexp.last_match(1)}" -- cgit v1.2.3 From 12c454822aff7320cee503c0708d30a99f4a0e0c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 7 Aug 2017 11:16:36 +0100 Subject: sandbox: stop printing message. We’re always using the sandbox where possible now so this is just noise for the vast majority of our users. --- Library/Homebrew/dev-cmd/test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index c678171ac..ab2b0edb0 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -65,8 +65,6 @@ module Homebrew args << "--devel" end - Sandbox.print_sandbox_message if Sandbox.test? - Utils.safe_fork do if Sandbox.test? sandbox = Sandbox.new -- cgit v1.2.3 From dc5a2c1764b1da3cfa85d8910338eb72cd4da96c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 4 Aug 2017 16:24:29 +0200 Subject: Simplify CurlDownloadStrategy. --- Library/Homebrew/dev-cmd/audit.rb | 8 +++----- Library/Homebrew/dev-cmd/mirror.rb | 10 +++++----- Library/Homebrew/dev-cmd/pull.rb | 16 ++++++++-------- 3 files changed, 16 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f07fa89e..b3e0785a5 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -242,12 +242,10 @@ class FormulaAuditor def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) max_time = hash_needed ? "600" : "25" - args = curl_args( - extra_args: ["--connect-timeout", "15", "--include", "--max-time", max_time, url], - show_output: true, - user_agent: user_agent, + output, = curl_output( + "--connect-timeout", "15", "--include", "--max-time", max_time, "--location", url, + user_agent: user_agent ) - output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } status_code = :unknown while status_code == :unknown || status_code.to_s.start_with?("3") diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index e2492203d..6445bc34c 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -25,9 +25,9 @@ module Homebrew "public_download_numbers": true, "public_stats": true} EOS - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-H", "Content-Type: application/json", - "-d", package_blob, bintray_repo_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--header", "Content-Type: application/json", + "--data", package_blob, bintray_repo_url puts end @@ -40,8 +40,8 @@ module Homebrew content_url = "https://api.bintray.com/content/homebrew/mirror" content_url += "/#{bintray_package}/#{f.pkg_version}/#{filename}" content_url += "?publish=1" - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-T", download, content_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--upload-file", download, content_url puts ohai "Mirrored #{filename}!" end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 9681bb2bc..dd2bc6270 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -228,7 +228,7 @@ module Homebrew "https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}" end - curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url + curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url safe_system "git", "checkout", "--quiet", "-B", bottle_branch, orig_revision pull_patch bottle_commit_url, "bottle commit" @@ -303,7 +303,7 @@ module Homebrew extra_msg = @description ? "(#{@description})" : nil ohai "Fetching patch #{extra_msg}" puts "Patch: #{patch_url}" - curl patch_url, "-s", "-o", patchpath + curl_download patch_url, to: patchpath end def apply_patch @@ -433,10 +433,10 @@ module Homebrew end version = info.pkg_version ohai "Publishing on Bintray: #{package} #{version}" - curl "-w", '\n', "--silent", "--fail", - "-u#{creds[:user]}:#{creds[:key]}", "-X", "POST", - "-H", "Content-Type: application/json", - "-d", '{"publish_wait_for_secs": 0}', + curl "--write-out", '\n', "--silent", "--fail", + "--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" true rescue => e @@ -587,7 +587,7 @@ module Homebrew # We're in the cache; make sure to force re-download loop do begin - curl url, "-o", filename + curl_download url, to: filename break rescue if retry_count >= max_curl_retries @@ -606,7 +606,7 @@ module Homebrew end def check_bintray_mirror(name, url) - headers = curl_output("--connect-timeout", "15", "--head", url)[0] + headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first return if status_code.start_with?("2") opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." -- cgit v1.2.3 From 986887b413897413266151c92d5071d0a82cf966 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Mon, 7 Aug 2017 14:31:56 -0700 Subject: Revert "Refactor SVN and cURL download strategies." --- Library/Homebrew/dev-cmd/audit.rb | 8 +++++--- Library/Homebrew/dev-cmd/mirror.rb | 10 +++++----- Library/Homebrew/dev-cmd/pull.rb | 16 ++++++++-------- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index b3e0785a5..1f07fa89e 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -242,10 +242,12 @@ class FormulaAuditor def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) max_time = hash_needed ? "600" : "25" - output, = curl_output( - "--connect-timeout", "15", "--include", "--max-time", max_time, "--location", url, - user_agent: user_agent + args = curl_args( + extra_args: ["--connect-timeout", "15", "--include", "--max-time", max_time, url], + show_output: true, + user_agent: user_agent, ) + output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } status_code = :unknown while status_code == :unknown || status_code.to_s.start_with?("3") diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index 6445bc34c..e2492203d 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -25,9 +25,9 @@ module Homebrew "public_download_numbers": true, "public_stats": true} EOS - curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", - "--header", "Content-Type: application/json", - "--data", package_blob, bintray_repo_url + curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", + "-H", "Content-Type: application/json", + "-d", package_blob, bintray_repo_url puts end @@ -40,8 +40,8 @@ module Homebrew content_url = "https://api.bintray.com/content/homebrew/mirror" content_url += "/#{bintray_package}/#{f.pkg_version}/#{filename}" content_url += "?publish=1" - curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", - "--upload-file", download, content_url + curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", + "-T", download, content_url puts ohai "Mirrored #{filename}!" end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index dd2bc6270..9681bb2bc 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -228,7 +228,7 @@ module Homebrew "https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}" end - curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url + curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url safe_system "git", "checkout", "--quiet", "-B", bottle_branch, orig_revision pull_patch bottle_commit_url, "bottle commit" @@ -303,7 +303,7 @@ module Homebrew extra_msg = @description ? "(#{@description})" : nil ohai "Fetching patch #{extra_msg}" puts "Patch: #{patch_url}" - curl_download patch_url, to: patchpath + curl patch_url, "-s", "-o", patchpath end def apply_patch @@ -433,10 +433,10 @@ module Homebrew end version = info.pkg_version ohai "Publishing on Bintray: #{package} #{version}" - curl "--write-out", '\n', "--silent", "--fail", - "--user", "#{creds[:user]}:#{creds[:key]}", "--request", "POST", - "--header", "Content-Type: application/json", - "--data", '{"publish_wait_for_secs": 0}', + curl "-w", '\n', "--silent", "--fail", + "-u#{creds[:user]}:#{creds[:key]}", "-X", "POST", + "-H", "Content-Type: application/json", + "-d", '{"publish_wait_for_secs": 0}', "https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish" true rescue => e @@ -587,7 +587,7 @@ module Homebrew # We're in the cache; make sure to force re-download loop do begin - curl_download url, to: filename + curl url, "-o", filename break rescue if retry_count >= max_curl_retries @@ -606,7 +606,7 @@ module Homebrew end def check_bintray_mirror(name, url) - headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) + headers = curl_output("--connect-timeout", "15", "--head", url)[0] status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first return if status_code.start_with?("2") opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." -- cgit v1.2.3 From ae4bafdb365cfa380d129b0a03bd99a1e4d960a4 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 8 Aug 2017 18:10:13 +0200 Subject: Simplify CurlDownloadStrategy. --- Library/Homebrew/dev-cmd/audit.rb | 8 +++----- Library/Homebrew/dev-cmd/mirror.rb | 10 +++++----- Library/Homebrew/dev-cmd/pull.rb | 16 ++++++++-------- 3 files changed, 16 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f07fa89e..b3e0785a5 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -242,12 +242,10 @@ class FormulaAuditor def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) max_time = hash_needed ? "600" : "25" - args = curl_args( - extra_args: ["--connect-timeout", "15", "--include", "--max-time", max_time, url], - show_output: true, - user_agent: user_agent, + output, = curl_output( + "--connect-timeout", "15", "--include", "--max-time", max_time, "--location", url, + user_agent: user_agent ) - output = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } status_code = :unknown while status_code == :unknown || status_code.to_s.start_with?("3") diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index e2492203d..6445bc34c 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -25,9 +25,9 @@ module Homebrew "public_download_numbers": true, "public_stats": true} EOS - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-H", "Content-Type: application/json", - "-d", package_blob, bintray_repo_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--header", "Content-Type: application/json", + "--data", package_blob, bintray_repo_url puts end @@ -40,8 +40,8 @@ module Homebrew content_url = "https://api.bintray.com/content/homebrew/mirror" content_url += "/#{bintray_package}/#{f.pkg_version}/#{filename}" content_url += "?publish=1" - curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}", - "-T", download, content_url + curl "--silent", "--fail", "--user", "#{bintray_user}:#{bintray_key}", + "--upload-file", download, content_url puts ohai "Mirrored #{filename}!" end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 9681bb2bc..dd2bc6270 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -228,7 +228,7 @@ module Homebrew "https://github.com/BrewTestBot/homebrew-#{tap.repo}/compare/homebrew:master...pr-#{issue}" end - curl "--silent", "--fail", "-o", "/dev/null", "-I", bottle_commit_url + curl "--silent", "--fail", "--output", "/dev/null", "--head", bottle_commit_url safe_system "git", "checkout", "--quiet", "-B", bottle_branch, orig_revision pull_patch bottle_commit_url, "bottle commit" @@ -303,7 +303,7 @@ module Homebrew extra_msg = @description ? "(#{@description})" : nil ohai "Fetching patch #{extra_msg}" puts "Patch: #{patch_url}" - curl patch_url, "-s", "-o", patchpath + curl_download patch_url, to: patchpath end def apply_patch @@ -433,10 +433,10 @@ module Homebrew end version = info.pkg_version ohai "Publishing on Bintray: #{package} #{version}" - curl "-w", '\n', "--silent", "--fail", - "-u#{creds[:user]}:#{creds[:key]}", "-X", "POST", - "-H", "Content-Type: application/json", - "-d", '{"publish_wait_for_secs": 0}', + curl "--write-out", '\n', "--silent", "--fail", + "--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" true rescue => e @@ -587,7 +587,7 @@ module Homebrew # We're in the cache; make sure to force re-download loop do begin - curl url, "-o", filename + curl_download url, to: filename break rescue if retry_count >= max_curl_retries @@ -606,7 +606,7 @@ module Homebrew end def check_bintray_mirror(name, url) - headers = curl_output("--connect-timeout", "15", "--head", url)[0] + headers, = curl_output("--connect-timeout", "15", "--location", "--head", url) status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first return if status_code.start_with?("2") opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." -- cgit v1.2.3 From e1ebaab0cbb3bfb050ea5db8e9ad35c17f90dfdf Mon Sep 17 00:00:00 2001 From: JCount Date: Tue, 8 Aug 2017 16:51:46 -0400 Subject: audit: fix mismatch in versioned alias names in non-core taps Fixes #3022 --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index b3e0785a5..170fb6d5f 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -328,6 +328,7 @@ class FormulaAuditor valid_alias_names = [alias_name_major, alias_name_major_minor] if formula.tap && !formula.tap.core_tap? + versioned_aliases.map! { |a| "#{formula.tap}/#{a}" } valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } end -- cgit v1.2.3 From 0ae22c0e3607ac3c2dba8627541ce275e9b0eb36 Mon Sep 17 00:00:00 2001 From: Bob W. Hogg Date: Mon, 7 Aug 2017 18:57:55 -0700 Subject: dev-cmd/bump-formula-pr: search for tar We first search for gtar in PATH, then check if Homebrew's gtar is available, then finally search for tar in PATH. Signed-off-by: Bob W. Hogg --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 1c56749a3..e9e98d450 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -176,7 +176,10 @@ module Homebrew rsrc.version = forced_version if forced_version odie "No version specified!" unless rsrc.version rsrc_path = rsrc.fetch - if Utils.popen_read("/usr/bin/tar", "-tf", rsrc_path) =~ %r{/.*\.} + gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar" + gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable? + tar = which("gtar") || gnu_tar_gtar || which("tar") + if Utils.popen_read(tar, "-tf", rsrc_path) =~ %r{/.*\.} new_hash = rsrc_path.sha256 elsif new_url.include? ".tar" odie "#{formula}: no url/#{hash_type} specified!" -- cgit v1.2.3 From 80ae5b2660d293adc9d1ad4aaa376500910a339a Mon Sep 17 00:00:00 2001 From: Mislav Marohnić Date: Tue, 15 Aug 2017 17:32:12 +0200 Subject: bump-formula-pr: forward compatibility with `hub fork` Due to limitations of `hub fork` in hub 2.2, scripts had to repeat the command at least two times; the 2nd time was to read the fork name from the "fatal: remote MYNAME already exists" message output from git. In upcoming hub 2.3, the `hub fork` command is improved to always output the remote name, regardless of whether one already existed or not. With this approach, only one `hub fork` call will ever be necessary when hub is up to date. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index e9e98d450..521c76302 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -296,9 +296,7 @@ module Homebrew ohai "git fetch --unshallow origin" if shallow ohai "git checkout --no-track -b #{branch} origin/master" ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}" - ohai "hub fork --no-remote" - ohai "hub fork" - ohai "hub fork (to read $HUB_REMOTE)" + ohai "hub fork # read $HUB_REMOTE" ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}" ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'" ohai "git checkout -" @@ -308,9 +306,9 @@ module Homebrew safe_system "git", "commit", "--no-edit", "--verbose", "--message=#{formula.name} #{new_formula_version}#{devel_message}", "--", formula.path - safe_system "hub", "fork", "--no-remote" - quiet_system "hub", "fork" - remote = Utils.popen_read("hub fork 2>&1")[/fatal: remote (.+) already exists\./, 1] + remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1] + # repeat for hub 2.2 backwards compatibility: + 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 -- cgit v1.2.3 From 15e572702e8dbd998e31aec110bce3cc0c9df811 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 21 Aug 2017 19:32:16 +0200 Subject: Fix `pull`. --- Library/Homebrew/dev-cmd/pull.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index dd2bc6270..a8f35531f 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -587,7 +587,7 @@ module Homebrew # We're in the cache; make sure to force re-download loop do begin - curl_download url, to: filename + curl_download url, continue_at: 0, to: filename break rescue if retry_count >= max_curl_retries -- cgit v1.2.3 From f0605f4a30ae1125ad2e3d8187a45af09b24def0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 23 Aug 2017 18:40:30 +0100 Subject: audit: don't output when searching taps. This messaging was added for the `brew search` command and having it in audit is annoying: (https://github.com/Homebrew/brew/pull/3059#issuecomment-323638672) As a side note: this is why randomly including `cmd/*` is a bad idea. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 170fb6d5f..89a6fb009 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -412,7 +412,7 @@ class FormulaAuditor same_name_tap_formulae = @@local_official_taps_name_map[name] || [] if @online - Homebrew.search_taps(name).each do |tap_formula_full_name| + Homebrew.search_taps(name, silent: true).each do |tap_formula_full_name| tap_formula_name = tap_formula_full_name.split("/").last next if tap_formula_name != name same_name_tap_formulae << tap_formula_full_name -- cgit v1.2.3 From 923c84d4f7c4e0cf09bfb417deb83bff2364c199 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 09:39:28 +0000 Subject: add some heuristics to https upgrade check --- Library/Homebrew/dev-cmd/audit.rb | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2c9336481..4fadae1a4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default]) + def self.check_http_content(type, url, name, user_agents: [:default]) return unless url.start_with? "http" details = nil @@ -236,8 +236,31 @@ class FormulaAuditor details[:content_length] == secure_details[:content_length] file_match = details[:file_hash] == secure_details[:file_hash] - return if !etag_match && !content_length_match && !file_match - "The URL #{url} could use HTTPS rather than HTTP" + if etag_match || content_length_match || file_match + return "The URL #{url} could use HTTPS rather than HTTP" + end + + if type == "homepage" + + details[:file] = details[:file].gsub(/https?:\\?\/\\?\//, '/') + secure_details[:file] = secure_details[:file].gsub(/https?:\\?\/\\?\//, '/') + + # Same content after normalization + if details[:file] == secure_details[:file] + return "The URL #{url} could use HTTPS rather than HTTP" + end + + # Same size, different content after normalization + # (typical causes: Generated ID, Timestamp, Unix time) + if details[:file].length == secure_details[:file].length + return "The URL #{url} could use HTTPS rather than HTTP" + end + + lenratio = (100 * secure_details[:file].length / details[:file].length).to_i + if lenratio >= 90 && lenratio <= 120 + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." + end + end end def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) @@ -260,6 +283,7 @@ class FormulaAuditor etag: headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2], content_length: headers[/Content-Length: (\d+)/, 1], file_hash: output_hash, + file: output, } end @@ -564,7 +588,8 @@ class FormulaAuditor return unless @online return unless DevelopmentTools.curl_handles_most_https_homepages? - if http_content_problem = FormulaAuditor.check_http_content(homepage, + if http_content_problem = FormulaAuditor.check_http_content("homepage", + homepage, formula.name, user_agents: [:browser, :default]) problem http_content_problem @@ -1219,7 +1244,8 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name) + if http_content_problem = FormulaAuditor.check_http_content("url", + url, name) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 11b267a7cfb3411c74c4fc21732463d543fc4fb3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 17:52:26 +0000 Subject: try addressing style issues --- Library/Homebrew/dev-cmd/audit.rb | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4fadae1a4..97fc93db9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -240,26 +240,25 @@ class FormulaAuditor return "The URL #{url} could use HTTPS rather than HTTP" end - if type == "homepage" + return if type != "homepage" - details[:file] = details[:file].gsub(/https?:\\?\/\\?\//, '/') - secure_details[:file] = secure_details[:file].gsub(/https?:\\?\/\\?\//, '/') + details[:file] = details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") + secure_details[:file] = secure_details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") - # Same content after normalization - if details[:file] == secure_details[:file] - return "The URL #{url} could use HTTPS rather than HTTP" - end + # Same content after normalization + if details[:file] == secure_details[:file] + return "The URL #{url} could use HTTPS rather than HTTP" + end - # Same size, different content after normalization - # (typical causes: Generated ID, Timestamp, Unix time) - if details[:file].length == secure_details[:file].length - return "The URL #{url} could use HTTPS rather than HTTP" - end + # Same size, different content after normalization + # (typical causes: Generated ID, Timestamp, Unix time) + if details[:file].length == secure_details[:file].length + return "The URL #{url} could use HTTPS rather than HTTP" + end - lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - if lenratio >= 90 && lenratio <= 120 - return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." - end + lenratio = (100 * secure_details[:file].length / details[:file].length).to_i + if lenratio >= 90 && lenratio <= 120 + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end end -- cgit v1.2.3 From 1c2c390c6fae78062c28a8ed1610936a4c2dd412 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 18:00:59 +0000 Subject: try addressing style issues #2 --- Library/Homebrew/dev-cmd/audit.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 97fc93db9..d468d69cb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -257,9 +257,8 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - if lenratio >= 90 && lenratio <= 120 - return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." - end + return if lenratio < 90 || lenratio > 120 + "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) -- cgit v1.2.3 From 53be6bb4bd69eaf8cc8e5c3c1ac9ecd1ddb1582c Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Thu, 27 Jul 2017 04:40:27 +0530 Subject: Added check for svn availability --- Library/Homebrew/dev-cmd/audit.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2c9336481..0e4500a12 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1228,7 +1228,9 @@ class ResourceAuditor end elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? - unless Utils.svn_remote_exists url + if !Utils.svn_available? + problem "No valid version of svn found" + elsif Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From 3d8873ca5b6270351ac8e4260fba8a41f8c0fe04 Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Tue, 29 Aug 2017 16:14:00 +0530 Subject: url skipped if svn not available when auditing urls --- Library/Homebrew/dev-cmd/audit.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0e4500a12..be332481c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1228,9 +1228,8 @@ class ResourceAuditor end elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? - if !Utils.svn_available? - problem "No valid version of svn found" - elsif Utils.svn_remote_exists url + next unless Utils.svn_available? + if Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From c30b94135853b809eda34c5c347c549bbf08a42d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 12:31:07 +0000 Subject: review follow-up #1 --- Library/Homebrew/dev-cmd/audit.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d468d69cb..5a86c0adf 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(type, url, name, user_agents: [:default]) + def self.check_http_content(url, name, user_agents: [:default], check_content: false) return unless url.start_with? "http" details = nil @@ -237,23 +237,24 @@ class FormulaAuditor file_match = details[:file_hash] == secure_details[:file_hash] if etag_match || content_length_match || file_match - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} should use HTTPS rather than HTTP" end - return if type != "homepage" + return unless check_content - details[:file] = details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") - secure_details[:file] = secure_details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") + no_protocol_file_contents = %r{https?:\\?/\\?/} + details[:file] = details[:file].gsub(no_protocol_file_contents, "/") + secure_details[:file] = secure_details[:file].gsub(no_protocol_file_contents, "/") - # Same content after normalization + # Check for the same content after removing all protocols if details[:file] == secure_details[:file] - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} should use HTTPS rather than HTTP" end # Same size, different content after normalization # (typical causes: Generated ID, Timestamp, Unix time) if details[:file].length == secure_details[:file].length - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i @@ -586,10 +587,10 @@ class FormulaAuditor return unless @online return unless DevelopmentTools.curl_handles_most_https_homepages? - if http_content_problem = FormulaAuditor.check_http_content("homepage", - homepage, + if http_content_problem = FormulaAuditor.check_http_content(homepage, formula.name, - user_agents: [:browser, :default]) + user_agents: [:browser, :default], + check_content: true) problem http_content_problem end end @@ -1242,8 +1243,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content("url", - url, name) + if http_content_problem = FormulaAuditor.check_http_content(url, name) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 56ccf10efaac5f97bae6b2e5aef9ef87d7529328 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 12:53:45 +0000 Subject: limit some heuristics to strict mode --- Library/Homebrew/dev-cmd/audit.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5a86c0adf..17948ea2c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default], check_content: false) + def self.check_http_content(url, name, user_agents: [:default], check_content: false, strict: false) return unless url.start_with? "http" details = nil @@ -251,6 +251,8 @@ class FormulaAuditor return "The URL #{url} should use HTTPS rather than HTTP" end + return unless strict + # Same size, different content after normalization # (typical causes: Generated ID, Timestamp, Unix time) if details[:file].length == secure_details[:file].length @@ -590,7 +592,8 @@ class FormulaAuditor if http_content_problem = FormulaAuditor.check_http_content(homepage, formula.name, user_agents: [:browser, :default], - check_content: true) + check_content: true, + strict: @strict) problem http_content_problem end end -- cgit v1.2.3 From 18f5b43d9001955784e235ce7f87068038175a82 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 17:02:27 +0000 Subject: fix length ratio range --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 17948ea2c..93aab6384 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -260,7 +260,7 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - return if lenratio < 90 || lenratio > 120 + return if lenratio < 90 || lenratio > 110 "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end -- cgit v1.2.3 From f301e5c4f4a3094aa9a1a1cf76a34efbd04b838d Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Thu, 31 Aug 2017 21:33:09 +0100 Subject: audit: add a nudge to remove ENV.java_cache --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index be332481c..3c6867f45 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -869,6 +869,10 @@ class FormulaAuditor problem "Use \"depends_on :x11\" instead of \"ENV.x11\"" end + 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)}\"" -- cgit v1.2.3 From 42e2c71dbc9c744fdabab70bf51dce106a76f0a6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 1 Sep 2017 16:47:31 +0000 Subject: cleanup range check --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 93aab6384..f6a8b10a6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -260,7 +260,7 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - return if lenratio < 90 || lenratio > 110 + return unless (90..110).cover?(lenratio) "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end -- cgit v1.2.3 From bbf71921eb2b2cce5072bb615fac3a2bc96fcfc7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 3 Sep 2017 21:42:46 +0100 Subject: audit: fix subversion remote check logic. Stop flagging invalid URLs as valid and vice-versa. Fixes #3118. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 3c6867f45..d8306609b 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1233,7 +1233,7 @@ class ResourceAuditor elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? next unless Utils.svn_available? - if Utils.svn_remote_exists url + unless Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From 267def28faab69388be3bc6347c0644f6ca812e8 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Fri, 4 Aug 2017 01:18:00 +0530 Subject: audit: Port rules from line_problems to rubocop part 3 --- Library/Homebrew/dev-cmd/audit.rb | 47 --------------------------------------- 1 file changed, 47 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..87377bd77 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -892,10 +892,6 @@ class FormulaAuditor problem "Use spaces instead of tabs for indentation" if line =~ /^[ ]*\t/ - if line.include?("ENV.x11") - problem "Use \"depends_on :x11\" instead of \"ENV.x11\"" - end - if line.include?("ENV.java_cache") problem "In-formula ENV.java_cache usage has been deprecated & should be removed." end @@ -913,14 +909,6 @@ class FormulaAuditor problem "Use ENV instead of invoking '#{Regexp.last_match(1)}' to modify the environment" end - if formula.name != "wine" && line =~ /ENV\.universal_binary/ - problem "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated." - end - - if line =~ /build\.universal\?/ - problem "macOS has been 64-bit only so build.universal? is deprecated." - end - if line =~ /version == ['"]HEAD['"]/ problem "Use 'build.head?' instead of inspecting 'version'" end @@ -961,12 +949,6 @@ class FormulaAuditor problem "Use build instead of ARGV to check options" end - problem "Use new-style option definitions" if line.include?("def options") - - if line.end_with?("def test") - problem "Use new-style test definitions (test do)" - end - if line.include?("MACOS_VERSION") problem "Use MacOS.version instead of MACOS_VERSION" end @@ -980,11 +962,6 @@ class FormulaAuditor problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead" end - if line =~ /skip_clean\s+:all/ - problem "`skip_clean :all` is deprecated; brew no longer strips symbols\n" \ - "\tPass explicit paths to prevent Homebrew from removing empty folders." - end - if line =~ /depends_on [A-Z][\w:]+\.new$/ problem "`depends_on` can take requirement classes instead of instances" end @@ -1023,30 +1000,6 @@ class FormulaAuditor problem "Use `assert_match` instead of `assert ...include?`" end - if line.include?('system "npm", "install"') && !line.include?("Language::Node") && - formula.name !~ /^kibana(\@\d+(\.\d+)?)?$/ - problem "Use Language::Node for npm install args" - end - - if line.include?("fails_with :llvm") - problem "'fails_with :llvm' is now a no-op so should be removed" - end - - if line =~ /system\s+['"](otool|install_name_tool|lipo)/ && formula.name != "cctools" - problem "Use ruby-macho instead of calling #{Regexp.last_match(1)}" - end - - if formula.tap.to_s == "homebrew/core" - ["OS.mac?", "OS.linux?"].each do |check| - next unless line.include?(check) - problem "Don't use #{check}; Homebrew/core only supports macOS" - end - end - - if line =~ /((revision|version_scheme)\s+0)/ - problem "'#{Regexp.last_match(1)}' should be removed" - end - return unless @strict problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/ -- cgit v1.2.3 From 4ec26aea4025d19e70cdf59da6dfd7be3a389e44 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Mon, 4 Sep 2017 13:47:05 +0530 Subject: audit: Port audit_class to rubocop, add tests and autocorrect --- Library/Homebrew/dev-cmd/audit.rb | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..1f8acb1b9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -381,21 +381,6 @@ class FormulaAuditor end end - def audit_class - if @strict - unless formula.test_defined? - problem "A `test do` test block should be added" - end - end - - classes = %w[GithubGistFormula ScriptFileFormula AmazonWebServicesFormula] - klass = classes.find do |c| - Object.const_defined?(c) && formula.class < Object.const_get(c) - end - - problem "#{klass} is deprecated, use Formula instead" if klass - end - # core aliases + tap alias names + tap alias full name @@aliases ||= Formula.aliases + Formula.tap_aliases -- cgit v1.2.3 From d45ff9c0fdfa834c55c01f9c95fe18064fabd76a Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sat, 2 Sep 2017 12:38:18 +0530 Subject: audit: Add a global flag to silent warning when auditing --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f8acb1b9..884861c87 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -54,6 +54,7 @@ module Homebrew def audit Homebrew.inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D" + Homebrew.auditing = true formula_count = 0 problem_count = 0 -- cgit v1.2.3 From 9562cceef15977306c9664f4f19892992a63e44a Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Tue, 5 Sep 2017 03:35:44 +0100 Subject: audit: stop demanding a HTTP HEAD mirror for curl Not sure if this is how you want to handle it but having a HEAD mirror for `curl` is just silliness. Ref: https://github.com/Homebrew/homebrew-core/commit/e36b95849ae38ade30605155d75cf6e731b4e38f --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..cfc57ac92 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1237,7 +1237,7 @@ class ResourceAuditor def audit_urls urls = [url] + mirrors - if name == "curl" && !urls.find { |u| u.start_with?("http://") } + if name == "curl" && !urls.find { |u| u.start_with?("http://") } && url != Formula["curl"].head.url problem "should always include at least one HTTP url" end -- cgit v1.2.3 From 03ace9b1104f1ddc2adc75a68531167d7e3ea7e0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 14 Sep 2017 19:58:37 +0100 Subject: Require more HTTP mirrors for old OS X versions. This allows the bootstrap of `curl` and `git` on versions of Mac OS X that cannot reliably download from HTTPS servers any longer. Once these are both installed users are able to update Homebrew and download files securely. Also, as we're doing this, don't point 10.5 users to Tigerbrew as they are already given caveats for using Homebrew itself. --- Library/Homebrew/dev-cmd/audit.rb | 47 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index bec035567..783237826 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -202,12 +202,12 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default], check_content: false, strict: false) + def self.check_http_content(url, user_agents: [:default], check_content: false, strict: false, require_http: false) return unless url.start_with? "http" details = nil user_agent = nil - hash_needed = url.start_with?("http:") && name != "curl" + hash_needed = url.start_with?("http:") && !require_http user_agents.each do |ua| details = http_content_headers_and_checksum(url, hash_needed: hash_needed, user_agent: ua) user_agent = ua @@ -576,7 +576,6 @@ class FormulaAuditor return unless DevelopmentTools.curl_handles_most_https_homepages? if http_content_problem = FormulaAuditor.check_http_content(homepage, - formula.name, user_agents: [:browser, :default], check_content: true, strict: @strict) @@ -629,13 +628,14 @@ class FormulaAuditor end %w[Stable Devel HEAD].each do |name| - next unless spec = formula.send(name.downcase) + spec_name = name.downcase.to_sym + next unless spec = formula.send(spec_name) - ra = ResourceAuditor.new(spec, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name}: #{problem}" } spec.resources.each_value do |resource| - ra = ResourceAuditor.new(resource, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name} resource #{resource.name.inspect}: #{problem}" } @@ -1086,10 +1086,10 @@ class FormulaAuditor end class ResourceAuditor - attr_reader :problems - attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name + attr_reader :name, :version, :checksum, :url, :mirrors, :using, :specs, :owner + attr_reader :spec_name, :problems - def initialize(resource, options = {}) + def initialize(resource, spec_name, options = {}) @name = resource.name @version = resource.version @checksum = resource.checksum @@ -1097,9 +1097,11 @@ class ResourceAuditor @mirrors = resource.mirrors @using = resource.using @specs = resource.specs - @online = options[:online] - @strict = options[:strict] - @problems = [] + @owner = resource.owner + @spec_name = spec_name + @online = options[:online] + @strict = options[:strict] + @problems = [] end def audit @@ -1173,11 +1175,26 @@ class ResourceAuditor problem "Redundant :using value in URL" end + def self.curl_git_openssl_and_deps + @curl_git_openssl_and_deps ||= begin + formulae_names = ["curl", "git", "openssl"] + formulae_names += formulae_names.flat_map do |f| + Formula[f].recursive_dependencies.map(&:name) + end + formulae_names.uniq + rescue FormulaUnavailableError + [] + end + end + def audit_urls urls = [url] + mirrors - if name == "curl" && !urls.find { |u| u.start_with?("http://") } && url != Formula["curl"].head.url - problem "should always include at least one HTTP url" + require_http = ResourceAuditor.curl_git_openssl_and_deps.include?(owner.name) + + if spec_name == :stable && require_http && + !urls.find { |u| u.start_with?("http://") } + problem "should always include at least one HTTP mirror" end return unless @online @@ -1189,7 +1206,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name) + if http_content_problem = FormulaAuditor.check_http_content(url, name, require_http: require_http) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 2e43d95498eedd3c61f7c013a0a419c2c0aac098 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 15 Sep 2017 10:17:40 +0100 Subject: audit: fix check_http_content args. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 783237826..4220fce47 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1206,7 +1206,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name, require_http: require_http) + if http_content_problem = FormulaAuditor.check_http_content(url, require_http: require_http) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From ffdda0eb9f4a2e56366e8c665d147d9be637f6f4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 16 Sep 2017 12:41:08 +0100 Subject: Tweaks for older Mac OS X versions. - `brew update` should try to install `curl` before `git` on older versions of Mac OS X where it is needed for accessing modern SSL certificates. - We don't need an HTTP mirror for `git` because `curl` will already be installed before it is downloaded. - Don't recommend GCC on Mac OS X versions where it can't be built with the default system compiler. - Start using the Homebrew `curl` on Mac OS X versions where it is needed as soon as it is installed. --- Library/Homebrew/dev-cmd/audit.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4220fce47..e2a288fdb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -574,7 +574,7 @@ class FormulaAuditor return unless @online - return unless DevelopmentTools.curl_handles_most_https_homepages? + return unless DevelopmentTools.curl_handles_most_https_certificates? if http_content_problem = FormulaAuditor.check_http_content(homepage, user_agents: [:browser, :default], check_content: true, @@ -1175,9 +1175,9 @@ class ResourceAuditor problem "Redundant :using value in URL" end - def self.curl_git_openssl_and_deps - @curl_git_openssl_and_deps ||= begin - formulae_names = ["curl", "git", "openssl"] + def self.curl_openssl_and_deps + @curl_openssl_and_deps ||= begin + formulae_names = ["curl", "openssl"] formulae_names += formulae_names.flat_map do |f| Formula[f].recursive_dependencies.map(&:name) end @@ -1190,11 +1190,14 @@ class ResourceAuditor def audit_urls urls = [url] + mirrors - require_http = ResourceAuditor.curl_git_openssl_and_deps.include?(owner.name) + curl_openssl_or_deps = ResourceAuditor.curl_openssl_and_deps.include?(owner.name) - if spec_name == :stable && require_http && - !urls.find { |u| u.start_with?("http://") } - problem "should always include at least one HTTP mirror" + if spec_name == :stable && curl_openssl_or_deps + problem "should not use xz tarballs" if url.end_with?(".xz") + + unless urls.find { |u| u.start_with?("http://") } + problem "should always include at least one HTTP mirror" + end end return unless @online @@ -1206,7 +1209,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, require_http: require_http) + if http_content_problem = FormulaAuditor.check_http_content(url, require_http: curl_openssl_or_deps) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 56ab1ef5a860beb2f180bbf26bfc74a0d569dce9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 23 Sep 2017 21:10:25 +0100 Subject: audit: hack around El Capitan audit failure. --- Library/Homebrew/dev-cmd/audit.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index e2a288fdb..5d1871f54 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -214,7 +214,12 @@ class FormulaAuditor break if details[:status].to_s.start_with?("2") end - return "The URL #{url} is not reachable" unless details[:status] + unless details[:status] + # Hack around https://github.com/Homebrew/brew/issues/3199 + return if MacOS.version == :el_capitan + return "The URL #{url} is not reachable" + end + unless details[:status].start_with? "2" return "The URL #{url} is not reachable (HTTP status code #{details[:status]})" end -- cgit v1.2.3 From e984623214d2a55d30c342e0a4607eb2fe56d017 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 23 Sep 2017 23:00:29 -0700 Subject: audit: don't check for homebrew/science duplicates It's just noise to turn the migration PRs red over expected duplicates. --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5d1871f54..a9768c856 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -419,6 +419,7 @@ class FormulaAuditor @@local_official_taps_name_map ||= Tap.select(&:official?).flat_map(&:formula_names) .each_with_object({}) do |tap_formula_full_name, name_map| + next if tap_formula_full_name.start_with?("homebrew/science/") tap_formula_name = tap_formula_full_name.split("/").last name_map[tap_formula_name] ||= [] name_map[tap_formula_name] << tap_formula_full_name -- cgit v1.2.3 From 28c78384501e159ecb45e0ffa29ff419a22701d8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sun, 24 Sep 2017 00:29:34 -0700 Subject: audit: also skip homebrew/science duplicates found by search_taps Follow-up to #3202. --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index a9768c856..743b9484e 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -430,6 +430,7 @@ class FormulaAuditor if @online Homebrew.search_taps(name, silent: true).each do |tap_formula_full_name| + next if tap_formula_full_name.start_with?("homebrew/science/") tap_formula_name = tap_formula_full_name.split("/").last next if tap_formula_name != name same_name_tap_formulae << tap_formula_full_name -- cgit v1.2.3 From 01e9ec9a9f723b2ef89c7adfaea39f9e4db9aede Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 24 Sep 2017 19:24:46 +0100 Subject: Rubocop: automatic rule fixes. --- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- Library/Homebrew/dev-cmd/bottle.rb | 2 +- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/pull.rb | 4 ++-- Library/Homebrew/dev-cmd/release-notes.rb | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 743b9484e..1fb89c3a4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -707,7 +707,7 @@ class FormulaAuditor end stable = formula.stable - case stable && stable.url + case stable&.url when /[\d\._-](alpha|beta|rc\d)/ matched = Regexp.last_match(1) version_prefix = stable.version.to_s.sub(/\d+$/, "") @@ -1018,7 +1018,7 @@ class FormulaAuditor def audit_reverse_migration # Only enforce for new formula being re-added to core and official taps return unless @strict - return unless formula.tap && formula.tap.official? + return unless formula.tap&.official? return unless formula.tap.tap_migrations.key?(formula.name) problem <<-EOS.undent diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index d8aefc4c0..577924a34 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -283,7 +283,7 @@ module Homebrew raise ensure ignore_interrupts do - original_tab.write if original_tab + original_tab&.write unless ARGV.include? "--skip-relocation" keg.replace_placeholders_with_locations changed_files end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 521c76302..87a239b98 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -124,7 +124,7 @@ module Homebrew Formula.each do |f| if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url) guesses << f - elsif f.stable && f.stable.url && f.stable.url.match(base_url) + elsif f.stable&.url && f.stable.url.match(base_url) guesses << f end end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index a8f35531f..931cba07f 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -75,7 +75,7 @@ module Homebrew tap = CoreTap.instance elsif (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/}) tap = ARGV.value("tap") - tap = if tap && tap.start_with?("homebrew/") + tap = if tap&.start_with?("homebrew/") Tap.fetch("homebrew", tap.strip_prefix("homebrew/")) elsif tap odie "Tap option did not start with \"homebrew/\": #{tap}" @@ -350,7 +350,7 @@ module Homebrew files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)} end files.each do |file| - if tap && tap.formula_file?(file) + if tap&.formula_file?(file) formula_name = File.basename(file, ".rb") formulae << formula_name unless formulae.include?(formula_name) else diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index e578869bf..496023956 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -10,10 +10,8 @@ module Homebrew def release_notes previous_tag = ARGV.named.first - unless previous_tag - previous_tag = Utils.popen_read("git tag --list --sort=-version:refname") + previous_tag ||= Utils.popen_read("git tag --list --sort=-version:refname") .lines.first.chomp - end odie "Could not find any previous tags!" unless previous_tag end_ref = ARGV.named[1] || "origin/master" -- cgit v1.2.3 From cf5fdeef1d8e9fd053121145882835b87eec2a43 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 24 Sep 2017 20:12:58 +0100 Subject: Rubocop: manual rule fixes. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 4 ++-- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/pull.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1fb89c3a4..a7d498c0d 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -358,7 +358,7 @@ class FormulaAuditor end valid_alias_names = [alias_name_major, alias_name_major_minor] - if formula.tap && !formula.tap.core_tap? + unless formula.tap&.core_tap? versioned_aliases.map! { |a| "#{formula.tap}/#{a}" } valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } end diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 577924a34..8dfd0d12c 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -47,7 +47,7 @@ BOTTLE_ERB = <<-EOS.freeze <% elsif cellar != BottleSpecification::DEFAULT_CELLAR %> cellar "<%= cellar %>" <% end %> - <% if rebuild > 0 %> + <% if rebuild.positive? %> rebuild <%= rebuild %> <% end %> <% checksums.each do |checksum_type, checksum_values| %> @@ -186,7 +186,7 @@ module Homebrew ohai "Determining #{f.full_name} bottle rebuild..." versions = FormulaVersions.new(f) rebuilds = versions.bottle_version_map("origin/master")[f.pkg_version] - rebuilds.pop if rebuilds.last.to_i > 0 + rebuilds.pop if rebuilds.last.to_i.positive? rebuild = rebuilds.empty? ? 0 : rebuilds.max.to_i + 1 end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 87a239b98..21abed7d9 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -89,7 +89,7 @@ module Homebrew def check_for_duplicate_pull_requests(formula) pull_requests = fetch_pull_requests(formula) - return unless pull_requests && !pull_requests.empty? + return unless pull_requests&.empty? duplicates_message = <<-EOS.undent These open pull requests may be duplicates: #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 931cba07f..cd0d6fbd0 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -69,7 +69,7 @@ module Homebrew tap = nil ARGV.named.each do |arg| - if arg.to_i > 0 + if arg.to_i.positive? issue = arg url = "https://github.com/Homebrew/homebrew-core/pull/#{arg}" tap = CoreTap.instance -- cgit v1.2.3 From feda0242be174c63925a7e982cc05d6e9748acd8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Mon, 25 Sep 2017 23:01:36 -0700 Subject: bump-formula-pr: fix duplicates check `return unless pull_requests && !pull_requests.empty?` and `return unless pull_requests&.empty?` are not equivalent. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 21abed7d9..87d8274cc 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -89,7 +89,8 @@ module Homebrew def check_for_duplicate_pull_requests(formula) pull_requests = fetch_pull_requests(formula) - return unless pull_requests&.empty? + return unless pull_requests + return if pull_requests.empty? duplicates_message = <<-EOS.undent These open pull requests may be duplicates: #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} -- cgit v1.2.3 From 134bd00d10a8feef63bd2583e117dc51be230db3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 29 Sep 2017 16:23:02 +0100 Subject: audit: don't care about shadowing official taps. We're trying to import all of these formulae anyway. --- Library/Homebrew/dev-cmd/audit.rb | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index a7d498c0d..49e7969af 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -396,7 +396,6 @@ class FormulaAuditor return if formula.tap.nil? || !formula.tap.official? name = formula.name - full_name = formula.full_name if Homebrew::MissingFormula.blacklisted_reason(name) problem "'#{name}' is blacklisted." @@ -412,35 +411,10 @@ class FormulaAuditor return end - if !formula.core_formula? && Formula.core_names.include?(name) - problem "Formula name conflicts with existing core formula." - return - end - - @@local_official_taps_name_map ||= Tap.select(&:official?).flat_map(&:formula_names) - .each_with_object({}) do |tap_formula_full_name, name_map| - next if tap_formula_full_name.start_with?("homebrew/science/") - tap_formula_name = tap_formula_full_name.split("/").last - name_map[tap_formula_name] ||= [] - name_map[tap_formula_name] << tap_formula_full_name - name_map - end - - same_name_tap_formulae = @@local_official_taps_name_map[name] || [] - - if @online - Homebrew.search_taps(name, silent: true).each do |tap_formula_full_name| - next if tap_formula_full_name.start_with?("homebrew/science/") - tap_formula_name = tap_formula_full_name.split("/").last - next if tap_formula_name != name - same_name_tap_formulae << tap_formula_full_name - end - end - - same_name_tap_formulae.delete(full_name) + return if formula.core_formula? + return unless Formula.core_names.include?(name) - return if same_name_tap_formulae.empty? - problem "Formula name conflicts with #{same_name_tap_formulae.join ", "}" + problem "Formula name conflicts with existing core formula." end def audit_deps -- cgit v1.2.3 From bcca2a7c6b80a6450bd8261af987a8da260b6b89 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 29 Sep 2017 19:53:15 +0100 Subject: brew: handle Ruby 2.3 more gracefully. - `brew.rb` needed updated to fail unless on Ruby 2.3 - `brew update` should unset `HOMEBREW_RUBY_PATH` to ensure that this doesn't "stick" on a Ruby 2.0 version after a portable Ruby has been installed. --- Library/Homebrew/dev-cmd/update-test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index aa7fe6a92..a66704917 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -81,7 +81,7 @@ module Homebrew safe_system "git", "reset", "--hard", start_commit # update ENV["PATH"] - ENV["PATH"] = "#{curdir}/bin:/usr/local/bin:/usr/bin:/bin" + ENV["PATH"] = "#{curdir}/bin:#{ENV["PATH"]}" # run brew update oh1 "Running brew update..." -- cgit v1.2.3 From 7cadff0a33d062b526d2ac246bd1d9e6cc689f53 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 29 Sep 2017 22:10:44 +0200 Subject: Use `PATH` where possible. --- Library/Homebrew/dev-cmd/update-test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index a66704917..1f1cdbeed 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -81,7 +81,7 @@ module Homebrew safe_system "git", "reset", "--hard", start_commit # update ENV["PATH"] - ENV["PATH"] = "#{curdir}/bin:#{ENV["PATH"]}" + ENV["PATH"] = PATH.new(ENV["PATH"]).prepend(curdir/"bin") # run brew update oh1 "Running brew update..." -- cgit v1.2.3 From 4e957165d14f14d7dc5a306bf9233ae17b6ed772 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Thu, 5 Oct 2017 02:52:21 +0100 Subject: audit: prefer assert/refute_predicate over File.exist? --- Library/Homebrew/dev-cmd/audit.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 49e7969af..ee5fb8df8 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -967,6 +967,14 @@ class FormulaAuditor problem "Use `assert_match` instead of `assert ...include?`" end + if line =~ /(assert File\.exist\?|File\.exist\?)/ + problem "Use `assert_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" + end + + if line =~ /(assert !File\.exist\?|!File\.exist\?)/ + problem "Use `refute_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" + end + return unless @strict problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/ -- cgit v1.2.3 From 2a25825a12897b7bfa167a720f24b6df03bdca94 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Sun, 8 Oct 2017 06:54:49 +0100 Subject: audit: tweak assert/refute_predicate audit Addresses some of the issues I raised in https://github.com/Homebrew/homebrew-core/pull/19127#issue-263566817. Would still like to work out a way to check `File.exist?`-style language inside the `test do` block exclusively but for now it's better to be too conservative on the audit than to be overly-zealous and flag too much. --- Library/Homebrew/dev-cmd/audit.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ee5fb8df8..16ae7cba1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -967,12 +967,12 @@ class FormulaAuditor problem "Use `assert_match` instead of `assert ...include?`" end - if line =~ /(assert File\.exist\?|File\.exist\?)/ + if line =~ /(assert File\.exist\?|assert \(.*\)\.exist\?)/ problem "Use `assert_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" end - if line =~ /(assert !File\.exist\?|!File\.exist\?)/ - problem "Use `refute_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" + if line =~ /assert !File\.exist\?/ + problem "Use `refute_predicate , :exist?` instead of `assert !File.exist?`" end return unless @strict -- cgit v1.2.3 From 175ca909ee1a5b57aa0cae2c879920511f311b14 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 7 Oct 2017 00:31:28 +0200 Subject: Clean up code style and remove `.rubocop_todo.yml`. --- Library/Homebrew/dev-cmd/aspell-dictionaries.rb | 5 ++--- Library/Homebrew/dev-cmd/audit.rb | 18 ++++++++++-------- Library/Homebrew/dev-cmd/bottle.rb | 9 +++------ Library/Homebrew/dev-cmd/man.rb | 9 +++------ Library/Homebrew/dev-cmd/pull.rb | 4 ++-- Library/Homebrew/dev-cmd/test.rb | 2 +- 6 files changed, 21 insertions(+), 26 deletions(-) (limited to 'Library/Homebrew/dev-cmd') 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..6afd1f802 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 @@ -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 diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 8dfd0d12c..fb862c773 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 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/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index cd0d6fbd0..8cb270303 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -154,8 +154,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 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 -- cgit v1.2.3 From 53dd0e3f28655f9e0ba93139cd832408542b6f12 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Fri, 6 Oct 2017 11:39:43 -0700 Subject: audit: Silence not notable on non-Homebrew taps Silence "GitHub repository not notable" on non-Homebrew taps. --- Library/Homebrew/dev-cmd/audit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 16ae7cba1..ff7161691 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -590,7 +590,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 -- cgit v1.2.3