Revert "Livecheck: Use Homebrew curl based on root domain"
This commit is contained in:
parent
e279c93c4b
commit
95213893a6
@ -6,7 +6,6 @@ source "https://rubygems.org"
|
|||||||
# * nokogiri - use rexml instead for XML parsing
|
# * nokogiri - use rexml instead for XML parsing
|
||||||
|
|
||||||
# installed gems (should all be require: false)
|
# installed gems (should all be require: false)
|
||||||
gem "addressable", require: false
|
|
||||||
gem "bootsnap", require: false
|
gem "bootsnap", require: false
|
||||||
gem "byebug", require: false
|
gem "byebug", require: false
|
||||||
gem "json_schemer", require: false
|
gem "json_schemer", require: false
|
||||||
|
@ -204,7 +204,6 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activesupport (< 7)
|
activesupport (< 7)
|
||||||
addressable
|
|
||||||
bootsnap
|
bootsnap
|
||||||
byebug
|
byebug
|
||||||
concurrent-ruby
|
concurrent-ruby
|
||||||
|
@ -5,7 +5,6 @@ require "livecheck/error"
|
|||||||
require "livecheck/livecheck_version"
|
require "livecheck/livecheck_version"
|
||||||
require "livecheck/skip_conditions"
|
require "livecheck/skip_conditions"
|
||||||
require "livecheck/strategy"
|
require "livecheck/strategy"
|
||||||
require "addressable"
|
|
||||||
require "ruby-progressbar"
|
require "ruby-progressbar"
|
||||||
require "uri"
|
require "uri"
|
||||||
|
|
||||||
@ -530,33 +529,26 @@ module Homebrew
|
|||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
# livecheck should fetch a URL using brewed curl if the formula/cask
|
# Fetch with brewed curl if using the download or homepage URL
|
||||||
# contains a `stable`/`url` or `head` URL `using: :homebrew_curl` that
|
# and the download URL specifies `using: :homebrew_curl`.
|
||||||
# shares the same root domain.
|
|
||||||
sig { params(formula_or_cask: T.any(Formula, Cask::Cask), url: String).returns(T::Boolean) }
|
sig { params(formula_or_cask: T.any(Formula, Cask::Cask), url: String).returns(T::Boolean) }
|
||||||
def use_homebrew_curl?(formula_or_cask, url)
|
def use_homebrew_curl?(formula_or_cask, url)
|
||||||
url_root_domain = Addressable::URI.parse(url)&.domain
|
if checkable_urls(formula_or_cask).include?(url)
|
||||||
return false if url_root_domain.blank?
|
case formula_or_cask
|
||||||
|
when Formula
|
||||||
|
[:stable, :head].any? do |spec_name|
|
||||||
|
next false unless (spec = formula_or_cask.send(spec_name))
|
||||||
|
|
||||||
# Collect root domains of URLs with `using: :homebrew_curl`
|
spec.using == :homebrew_curl
|
||||||
homebrew_curl_root_domains = []
|
end
|
||||||
case formula_or_cask
|
when Cask::Cask
|
||||||
when Formula
|
formula_or_cask.url.using == :homebrew_curl
|
||||||
[:stable, :head].each do |spec_name|
|
else
|
||||||
next unless (spec = formula_or_cask.send(spec_name))
|
T.absurd(formula_or_cask)
|
||||||
next unless spec.using == :homebrew_curl
|
|
||||||
|
|
||||||
domain = Addressable::URI.parse(spec.url)&.domain
|
|
||||||
homebrew_curl_root_domains << domain if domain.present?
|
|
||||||
end
|
end
|
||||||
when Cask::Cask
|
else
|
||||||
return false unless formula_or_cask.url.using == :homebrew_curl
|
false
|
||||||
|
|
||||||
domain = Addressable::URI.parse(formula_or_cask.url.to_s)&.domain
|
|
||||||
homebrew_curl_root_domains << domain if domain.present?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
homebrew_curl_root_domains.include?(url_root_domain)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Identifies the latest version of the formula and returns a Hash containing
|
# Identifies the latest version of the formula and returns a Hash containing
|
||||||
@ -670,7 +662,6 @@ module Homebrew
|
|||||||
when "PageMatch", "HeaderMatch"
|
when "PageMatch", "HeaderMatch"
|
||||||
use_homebrew_curl?((referenced_formula_or_cask || formula_or_cask), url)
|
use_homebrew_curl?((referenced_formula_or_cask || formula_or_cask), url)
|
||||||
end
|
end
|
||||||
puts "Homebrew curl?: Yes" if debug && homebrew_curl.present?
|
|
||||||
|
|
||||||
strategy_data = strategy.find_versions(
|
strategy_data = strategy.find_versions(
|
||||||
url: url,
|
url: url,
|
||||||
@ -752,7 +743,6 @@ module Homebrew
|
|||||||
version_info[:meta][:url][:strategy] = strategy_data[:url]
|
version_info[:meta][:url][:strategy] = strategy_data[:url]
|
||||||
end
|
end
|
||||||
version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
|
version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
|
||||||
version_info[:meta][:url][:homebrew_curl] = homebrew_curl if homebrew_curl.present?
|
|
||||||
|
|
||||||
version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
||||||
version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] } if strategies.present?
|
version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] } if strategies.present?
|
||||||
|
@ -16,7 +16,7 @@ describe Homebrew::Livecheck do
|
|||||||
formula("test") do
|
formula("test") do
|
||||||
desc "Test formula"
|
desc "Test formula"
|
||||||
homepage "https://brew.sh"
|
homepage "https://brew.sh"
|
||||||
url "https://brew.sh/test-0.0.1.tgz"
|
url "https://brew.sh/test-0.0.1.tgz", using: :homebrew_curl
|
||||||
head "https://github.com/Homebrew/brew.git"
|
head "https://github.com/Homebrew/brew.git"
|
||||||
|
|
||||||
livecheck do
|
livecheck do
|
||||||
@ -31,7 +31,7 @@ describe Homebrew::Livecheck do
|
|||||||
cask "test" do
|
cask "test" do
|
||||||
version "0.0.1,2"
|
version "0.0.1,2"
|
||||||
|
|
||||||
url "https://brew.sh/test-0.0.1.dmg"
|
url "https://brew.sh/test-0.0.1.dmg", using: :homebrew_curl
|
||||||
name "Test"
|
name "Test"
|
||||||
desc "Test cask"
|
desc "Test cask"
|
||||||
homepage "https://brew.sh"
|
homepage "https://brew.sh"
|
||||||
@ -158,67 +158,13 @@ describe Homebrew::Livecheck do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::use_homebrew_curl?" do
|
describe "::use_homebrew_curl?" do
|
||||||
let(:example_url) { "https://www.example.com/test-0.0.1.tgz" }
|
it "uses brewed curl if called for by the download URL" do
|
||||||
|
|
||||||
let(:f_homebrew_curl) do
|
|
||||||
formula("test") do
|
|
||||||
desc "Test formula"
|
|
||||||
homepage "https://brew.sh"
|
|
||||||
url "https://brew.sh/test-0.0.1.tgz", using: :homebrew_curl
|
|
||||||
# head is deliberably omitted to exercise more of the method
|
|
||||||
|
|
||||||
livecheck do
|
|
||||||
url "https://formulae.brew.sh/api/formula/ruby.json"
|
|
||||||
regex(/"stable":"(\d+(?:\.\d+)+)"/i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:c_homebrew_curl) do
|
|
||||||
Cask::CaskLoader.load(+<<-RUBY)
|
|
||||||
cask "test" do
|
|
||||||
version "0.0.1,2"
|
|
||||||
|
|
||||||
url "https://brew.sh/test-0.0.1.dmg", using: :homebrew_curl
|
|
||||||
name "Test"
|
|
||||||
desc "Test cask"
|
|
||||||
homepage "https://brew.sh"
|
|
||||||
|
|
||||||
livecheck do
|
|
||||||
url "https://formulae.brew.sh/api/formula/ruby.json"
|
|
||||||
regex(/"stable":"(\d+(?:\.\d+)+)"/i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
RUBY
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns `true` when URL matches a `using: :homebrew_curl` URL" do
|
|
||||||
expect(livecheck.use_homebrew_curl?(f_homebrew_curl, livecheck_url)).to be(true)
|
|
||||||
expect(livecheck.use_homebrew_curl?(f_homebrew_curl, homepage_url)).to be(true)
|
|
||||||
expect(livecheck.use_homebrew_curl?(f_homebrew_curl, stable_url)).to be(true)
|
|
||||||
expect(livecheck.use_homebrew_curl?(c_homebrew_curl, livecheck_url)).to be(true)
|
|
||||||
expect(livecheck.use_homebrew_curl?(c_homebrew_curl, homepage_url)).to be(true)
|
|
||||||
expect(livecheck.use_homebrew_curl?(c_homebrew_curl, cask_url)).to be(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns `false` if URL root domain differs from `using: :homebrew_curl` URLs" do
|
|
||||||
expect(livecheck.use_homebrew_curl?(f_homebrew_curl, example_url)).to be(false)
|
|
||||||
expect(livecheck.use_homebrew_curl?(c_homebrew_curl, example_url)).to be(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns `false` if a `using: homebrew_curl` URL is not present" do
|
|
||||||
expect(livecheck.use_homebrew_curl?(f, livecheck_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(f, livecheck_url)).to be(false)
|
||||||
expect(livecheck.use_homebrew_curl?(f, homepage_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(f, homepage_url)).to be(true)
|
||||||
expect(livecheck.use_homebrew_curl?(f, stable_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(f, stable_url)).to be(true)
|
||||||
expect(livecheck.use_homebrew_curl?(f, example_url)).to be(false)
|
|
||||||
expect(livecheck.use_homebrew_curl?(c, livecheck_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(c, livecheck_url)).to be(false)
|
||||||
expect(livecheck.use_homebrew_curl?(c, homepage_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(c, homepage_url)).to be(true)
|
||||||
expect(livecheck.use_homebrew_curl?(c, cask_url)).to be(false)
|
expect(livecheck.use_homebrew_curl?(c, cask_url)).to be(true)
|
||||||
expect(livecheck.use_homebrew_curl?(c, example_url)).to be(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns `false` if URL string does not contain a domain" do
|
|
||||||
expect(livecheck.use_homebrew_curl?(f_homebrew_curl, "test")).to be(false)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user