From ff2b1d6821afe55c6bcbb94b5c15bdcc3e00be09 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 3 Aug 2025 09:47:59 -0400 Subject: [PATCH 1/2] SkipConditions: special case unsigned deprecations We've been adding `disable!` calls with a future date to casks using an unsigned app. That implicitly deprecates the cask until it reaches the disable date, so we've been having to add simple `livecheck` blocks to casks that use a default check to ensure that livecheck continues to check them. It was suggested that it would be simpler to have livecheck not skip casks that have a `disable!` call with a `because: :unsigned` argument and I agree, so this modifies `SkipConditions` to add a special case for this scenario. --- Library/Homebrew/livecheck/skip_conditions.rb | 1 + .../test/livecheck/skip_conditions_spec.rb | 32 ++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/livecheck/skip_conditions.rb b/Library/Homebrew/livecheck/skip_conditions.rb index 4ed474dea6..a8212b3a08 100644 --- a/Library/Homebrew/livecheck/skip_conditions.rb +++ b/Library/Homebrew/livecheck/skip_conditions.rb @@ -120,6 +120,7 @@ module Homebrew } private_class_method def self.cask_deprecated(cask, livecheck_defined, full_name: false, verbose: false) return {} if !cask.deprecated? || livecheck_defined + return {} if cask.disable_date && cask.deprecation_reason == :unsigned Livecheck.status_hash(cask, "deprecated", full_name:, verbose:) end diff --git a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb index 0ea8445649..89c86f6a94 100644 --- a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb +++ b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb @@ -79,7 +79,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do let(:casks) do { - basic: Cask::Cask.new("test") do + basic: Cask::Cask.new("test") do version "0.0.1,2" url "https://brew.sh/test-0.0.1.tgz" @@ -92,7 +92,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do regex(/"stable":"(\d+(?:\.\d+)+)"/i) end end, - deprecated: Cask::Cask.new("test_deprecated") do + deprecated: Cask::Cask.new("test_deprecated") do version "0.0.1" sha256 :no_check @@ -103,7 +103,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do deprecate! date: "2020-06-25", because: :discontinued end, - disabled: Cask::Cask.new("test_disabled") do + disabled: Cask::Cask.new("test_disabled") do version "0.0.1" sha256 :no_check @@ -114,7 +114,17 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do disable! date: "2020-06-25", because: :discontinued end, - extract_plist: Cask::Cask.new("test_extract_plist_skip") do + future_disable_unsigned: Cask::Cask.new("test_future_disable_unsigned") do + version "0.0.1" + + url "https://brew.sh/test-#{version}.tgz" + name "Test Future Disabled Unsigned" + desc "Future Disable Unsigned test cask" + homepage "https://brew.sh" + + disable! date: "3000-06-25", because: :unsigned + end, + extract_plist: Cask::Cask.new("test_extract_plist_skip") do version "0.0.1" url "https://brew.sh/test-0.0.1.tgz" @@ -126,7 +136,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do strategy :extract_plist end end, - latest: Cask::Cask.new("test_latest") do + latest: Cask::Cask.new("test_latest") do version :latest sha256 :no_check @@ -135,7 +145,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do desc "Latest test cask" homepage "https://brew.sh" end, - unversioned: Cask::Cask.new("test_unversioned") do + unversioned: Cask::Cask.new("test_unversioned") do version "1.2.3" sha256 :no_check @@ -144,7 +154,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do desc "Unversioned test cask" homepage "https://brew.sh" end, - skip: Cask::Cask.new("test_skip") do + skip: Cask::Cask.new("test_skip") do version "0.0.1" url "https://brew.sh/test-0.0.1.tgz" @@ -156,7 +166,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do skip end end, - skip_with_message: Cask::Cask.new("test_skip_with_message") do + skip_with_message: Cask::Cask.new("test_skip_with_message") do version "0.0.1" url "https://brew.sh/test-0.0.1.tgz" @@ -374,6 +384,12 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do end end + context "when a cask without a `livecheck` block is deprecated with a future disable date because `:unsigned`" do + it "does not skip" do + expect(skip_conditions.skip_information(casks[:future_disable_unsigned])).to eq({}) + end + end + context "when a cask has a `livecheck` block using `ExtractPlist` and `--extract-plist` is not used" do it "skips" do expect(skip_conditions.skip_information(casks[:extract_plist], extract_plist: false)) From d06480aae141ab2748aa9189429a741e9ea78d37 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 3 Aug 2025 10:25:43 -0400 Subject: [PATCH 2/2] SkipConditions: use versioned URLs in test casks The `Cask::Cask` objects in the `SkipConditions` tests don't interpolate `version` in the `url` strings, so these are technically unversioned URLs as a result and would be skipped as unversioned. This updates the URLs accordingly, so they won't trigger the unversioned skip as a fallback (if the intended test doesn't work as expected). This is something I discovered while writing a test for a cask that shouldn't be skipped. --- .../Homebrew/test/livecheck/skip_conditions_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb index 89c86f6a94..94859b9404 100644 --- a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb +++ b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb @@ -82,7 +82,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do basic: Cask::Cask.new("test") do version "0.0.1,2" - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version.csv.first}.tgz" name "Test" desc "Test cask" homepage "https://brew.sh" @@ -96,7 +96,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do version "0.0.1" sha256 :no_check - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version}.tgz" name "Test Deprecate" desc "Deprecated test cask" homepage "https://brew.sh" @@ -107,7 +107,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do version "0.0.1" sha256 :no_check - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version}.tgz" name "Test Disable" desc "Disabled test cask" homepage "https://brew.sh" @@ -127,7 +127,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do extract_plist: Cask::Cask.new("test_extract_plist_skip") do version "0.0.1" - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version}.tgz" name "Test ExtractPlist Skip" desc "Skipped test cask" homepage "https://brew.sh" @@ -157,7 +157,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do skip: Cask::Cask.new("test_skip") do version "0.0.1" - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version}.tgz" name "Test Skip" desc "Skipped test cask" homepage "https://brew.sh" @@ -169,7 +169,7 @@ RSpec.describe Homebrew::Livecheck::SkipConditions do skip_with_message: Cask::Cask.new("test_skip_with_message") do version "0.0.1" - url "https://brew.sh/test-0.0.1.tgz" + url "https://brew.sh/test-#{version}.tgz" name "Test Skip" desc "Skipped test cask" homepage "https://brew.sh"