mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
repology: always use Homebrew curl.
This seems to be required even with TLSv1.3 support now. Also, while we're here, improve the error handling/output.
This commit is contained in:
parent
60afbd761a
commit
b09f421027
11
.github/workflows/tests.yml
vendored
11
.github/workflows/tests.yml
vendored
@ -228,6 +228,9 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-${{ github.sha }}
|
||||
restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-
|
||||
|
||||
- name: Install brew tests dependencies
|
||||
run: brew install curl
|
||||
|
||||
- name: Run brew tests
|
||||
run: |
|
||||
# brew tests doesn't like world writable directories
|
||||
@ -303,13 +306,7 @@ jobs:
|
||||
run: brew readall --aliases
|
||||
|
||||
- name: Install brew tests dependencies
|
||||
run: |
|
||||
brew install subversion
|
||||
brew sh -c "svn --homebrew=print-path"
|
||||
which svn
|
||||
which svnadmin
|
||||
brew install curl
|
||||
which curl
|
||||
run: brew install subversion curl
|
||||
|
||||
- name: Create parallel test log directory
|
||||
run: mkdir tests
|
||||
|
@ -56,14 +56,12 @@ module Homebrew
|
||||
|
||||
limit = args.limit.to_i if args.limit.present?
|
||||
|
||||
unless Utils::Curl.curl_supports_tls13?
|
||||
begin
|
||||
unless Pathname.new(ENV["HOMEBREW_BREWED_CURL_PATH"]).exist?
|
||||
ensure_formula_installed!("curl", reason: "Repology queries")
|
||||
end
|
||||
rescue FormulaUnavailableError
|
||||
opoo "A `curl` with TLS 1.3 support is required for Repology queries."
|
||||
end
|
||||
opoo "A newer `curl` is required for Repology queries."
|
||||
end
|
||||
|
||||
if formulae_and_casks.present?
|
||||
|
@ -6,7 +6,7 @@ require "cmd/shared_examples/args_parse"
|
||||
describe "brew bump" do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
describe "formula", :integration_test, :needs_network, :needs_tls13 do
|
||||
describe "formula", :integration_test, :needs_network, :needs_homebrew_curl do
|
||||
it "returns data for single valid specified formula" do
|
||||
install_test_formula "testball"
|
||||
|
||||
|
@ -169,11 +169,9 @@ RSpec.configure do |config|
|
||||
.append(svnadmin.dirname)
|
||||
end
|
||||
|
||||
config.before(:each, :needs_tls13) do
|
||||
unless curl_supports_tls13?
|
||||
config.before(:each, :needs_homebrew_curl) do
|
||||
ENV["HOMEBREW_CURL"] = ENV["HOMEBREW_BREWED_CURL_PATH"]
|
||||
skip "A `curl` with TLS 1.3 support is required." unless curl_supports_tls13?
|
||||
end
|
||||
rescue FormulaUnavailableError
|
||||
skip "No `curl` formula is available."
|
||||
end
|
||||
|
@ -4,7 +4,7 @@
|
||||
require "utils/repology"
|
||||
|
||||
describe Repology do
|
||||
describe "single_package_query", :needs_network, :needs_tls13 do
|
||||
describe "single_package_query", :needs_network, :needs_homebrew_curl do
|
||||
it "returns nil for non-existent package" do
|
||||
response = described_class.single_package_query("invalidName", repository: "homebrew")
|
||||
|
||||
@ -19,7 +19,7 @@ describe Repology do
|
||||
end
|
||||
end
|
||||
|
||||
describe "parse_api_response", :needs_network, :needs_tls13 do
|
||||
describe "parse_api_response", :needs_network, :needs_homebrew_curl do
|
||||
it "returns a hash of data" do
|
||||
limit = 1
|
||||
start_with = "x"
|
||||
|
@ -19,22 +19,35 @@ module Repology
|
||||
last_package_in_response += "/" if last_package_in_response.present?
|
||||
url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=#{repository}&outdated=1"
|
||||
|
||||
output, _errors, _status = curl_output(url.to_s, use_homebrew_curl: !curl_supports_tls13?)
|
||||
output, errors, = curl_output(url.to_s, "--silent", use_homebrew_curl: false)
|
||||
JSON.parse(output)
|
||||
rescue
|
||||
if Homebrew::EnvConfig.developer?
|
||||
$stderr.puts errors
|
||||
else
|
||||
odebug errors
|
||||
end
|
||||
|
||||
raise
|
||||
end
|
||||
|
||||
def single_package_query(name, repository:)
|
||||
url = "https://repology.org/tools/project-by?repo=#{repository}&" \
|
||||
"name_type=srcname&target_page=api_v1_project&name=#{name}"
|
||||
|
||||
output, _errors, _status = curl_output("--location", url.to_s, use_homebrew_curl: !curl_supports_tls13?)
|
||||
output, errors, = curl_output("--location", "--silent", url.to_s, use_homebrew_curl: true)
|
||||
|
||||
begin
|
||||
data = JSON.parse(output)
|
||||
{ name => data }
|
||||
rescue
|
||||
nil
|
||||
rescue => e
|
||||
error_output = [errors, "#{e.class}: #{e}", e.backtrace].compact
|
||||
if Homebrew::EnvConfig.developer?
|
||||
$stderr.puts(*error_output)
|
||||
else
|
||||
odebug(*error_output)
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
def parse_api_response(limit = nil, last_package = "", repository:)
|
||||
|
Loading…
x
Reference in New Issue
Block a user