From aae91cacae80a724efd119a2bcb9fc5371228e38 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 2 Jan 2021 18:01:10 -0500 Subject: [PATCH] Livecheck: Skip Internet Archive stable URLs --- Library/Homebrew/livecheck/livecheck.rb | 4 ++++ .../Homebrew/test/livecheck/livecheck_spec.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 8744118b0d..eaf32fbf7a 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -357,15 +357,19 @@ module Homebrew stable_from_google_code_archive = formula&.stable&.url&.match?( %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) if formula_or_cask.livecheck.skip? || ((stable_from_google_code_archive || + stable_from_internet_archive || stable_is_gist) && !formula&.livecheckable?) 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.to_s.presence elsif stable_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 "Stable URL is a GitHub Gist" end diff --git a/Library/Homebrew/test/livecheck/livecheck_spec.rb b/Library/Homebrew/test/livecheck/livecheck_spec.rb index 00539791fa..de46d7341d 100644 --- a/Library/Homebrew/test/livecheck/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck/livecheck_spec.rb @@ -241,6 +241,22 @@ describe Homebrew::Livecheck do 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 let(:f_skip) do formula("test_skip") do