From f36d1a7fb66ed548063a509ca3c7a522cd7737f6 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 2 Jan 2021 18:00:57 -0500 Subject: [PATCH] Livecheck: Skip Google Code Archive stable URLs --- Library/Homebrew/livecheck/livecheck.rb | 13 ++++++++++--- .../Homebrew/test/livecheck/livecheck_spec.rb | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 5561c5bce6..8744118b0d 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -354,12 +354,19 @@ module Homebrew return end - is_gist = formula&.stable&.url&.include?("gist.github.com") - if formula_or_cask.livecheck.skip? || is_gist + stable_from_google_code_archive = formula&.stable&.url&.match?( + %r{https?://storage\.googleapis\.com/google-code-archive-downloads/}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_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 is_gist + elsif stable_from_google_code_archive + "Stable URL is from Google Code 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 e4d583e40e..00539791fa 100644 --- a/Library/Homebrew/test/livecheck/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck/livecheck_spec.rb @@ -225,6 +225,22 @@ describe Homebrew::Livecheck do end end + context "a formula with a Google Code Archive stable URL" do + let(:f_google_code_archive) do + formula("test_google_code_archive") do + desc "Google Code Archive test formula" + homepage "https://brew.sh" + url "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/brew/brew-1.0.0.tar.gz" + end + end + + it "skips" do + expect { livecheck.skip_conditions(f_google_code_archive) } + .to output("test_google_code_archive : skipped - Stable URL is from Google Code 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