Livecheck: Skip Internet Archive stable URLs

This commit is contained in:
Sam Ford 2021-01-02 18:01:10 -05:00
parent f36d1a7fb6
commit aae91cacae
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE
2 changed files with 20 additions and 0 deletions

View File

@ -357,15 +357,19 @@ module Homebrew
stable_from_google_code_archive = formula&.stable&.url&.match?( stable_from_google_code_archive = formula&.stable&.url&.match?(
%r{https?://storage\.googleapis\.com/google-code-archive-downloads/}i, %r{https?://storage\.googleapis\.com/google-code-archive-downloads/}i,
) )
stable_from_internet_archive = formula&.stable&.url&.match?(%r{https?://web\.archive\.org/}i)
stable_is_gist = formula&.stable&.url&.match?(%r{https?://gist\.github(?:usercontent)?\.com/}i) stable_is_gist = formula&.stable&.url&.match?(%r{https?://gist\.github(?:usercontent)?\.com/}i)
if formula_or_cask.livecheck.skip? || if formula_or_cask.livecheck.skip? ||
((stable_from_google_code_archive || ((stable_from_google_code_archive ||
stable_from_internet_archive ||
stable_is_gist) && !formula&.livecheckable?) stable_is_gist) && !formula&.livecheckable?)
skip_message = if formula_or_cask.livecheck.skip_msg.is_a?(String) && skip_message = if formula_or_cask.livecheck.skip_msg.is_a?(String) &&
formula_or_cask.livecheck.skip_msg.present? formula_or_cask.livecheck.skip_msg.present?
formula_or_cask.livecheck.skip_msg.to_s.presence formula_or_cask.livecheck.skip_msg.to_s.presence
elsif stable_from_google_code_archive elsif stable_from_google_code_archive
"Stable URL is from Google Code Archive" "Stable URL is from Google Code Archive"
elsif stable_from_internet_archive
"Stable URL is from Internet Archive"
elsif stable_is_gist elsif stable_is_gist
"Stable URL is a GitHub Gist" "Stable URL is a GitHub Gist"
end end

View File

@ -241,6 +241,22 @@ describe Homebrew::Livecheck do
end end
end end
context "a formula with an Internet Archive stable URL" do
let(:f_internet_archive) do
formula("test_internet_archive") do
desc "Internet Archive test formula"
homepage "https://brew.sh"
url "https://web.archive.org/web/20200101000000/https://brew.sh/test-0.0.1.tgz"
end
end
it "skips" do
expect { livecheck.skip_conditions(f_internet_archive) }
.to output("test_internet_archive : skipped - Stable URL is from Internet Archive\n").to_stdout
.and not_to_output.to_stderr
end
end
context "a formula with a `livecheck` block containing `skip`" do context "a formula with a `livecheck` block containing `skip`" do
let(:f_skip) do let(:f_skip) do
formula("test_skip") do formula("test_skip") do