Skip to content

Commit ff2b1d6

Browse files
committed
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.
1 parent 563d066 commit ff2b1d6

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Library/Homebrew/livecheck/skip_conditions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module SkipConditions
120120
}
121121
private_class_method def self.cask_deprecated(cask, livecheck_defined, full_name: false, verbose: false)
122122
return {} if !cask.deprecated? || livecheck_defined
123+
return {} if cask.disable_date && cask.deprecation_reason == :unsigned
123124

124125
Livecheck.status_hash(cask, "deprecated", full_name:, verbose:)
125126
end

Library/Homebrew/test/livecheck/skip_conditions_spec.rb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979

8080
let(:casks) do
8181
{
82-
basic: Cask::Cask.new("test") do
82+
basic: Cask::Cask.new("test") do
8383
version "0.0.1,2"
8484

8585
url "https://brew.sh/test-0.0.1.tgz"
@@ -92,7 +92,7 @@
9292
regex(/"stable":"(\d+(?:\.\d+)+)"/i)
9393
end
9494
end,
95-
deprecated: Cask::Cask.new("test_deprecated") do
95+
deprecated: Cask::Cask.new("test_deprecated") do
9696
version "0.0.1"
9797
sha256 :no_check
9898

@@ -103,7 +103,7 @@
103103

104104
deprecate! date: "2020-06-25", because: :discontinued
105105
end,
106-
disabled: Cask::Cask.new("test_disabled") do
106+
disabled: Cask::Cask.new("test_disabled") do
107107
version "0.0.1"
108108
sha256 :no_check
109109

@@ -114,7 +114,17 @@
114114

115115
disable! date: "2020-06-25", because: :discontinued
116116
end,
117-
extract_plist: Cask::Cask.new("test_extract_plist_skip") do
117+
future_disable_unsigned: Cask::Cask.new("test_future_disable_unsigned") do
118+
version "0.0.1"
119+
120+
url "https://brew.sh/test-#{version}.tgz"
121+
name "Test Future Disabled Unsigned"
122+
desc "Future Disable Unsigned test cask"
123+
homepage "https://brew.sh"
124+
125+
disable! date: "3000-06-25", because: :unsigned
126+
end,
127+
extract_plist: Cask::Cask.new("test_extract_plist_skip") do
118128
version "0.0.1"
119129

120130
url "https://brew.sh/test-0.0.1.tgz"
@@ -126,7 +136,7 @@
126136
strategy :extract_plist
127137
end
128138
end,
129-
latest: Cask::Cask.new("test_latest") do
139+
latest: Cask::Cask.new("test_latest") do
130140
version :latest
131141
sha256 :no_check
132142

@@ -135,7 +145,7 @@
135145
desc "Latest test cask"
136146
homepage "https://brew.sh"
137147
end,
138-
unversioned: Cask::Cask.new("test_unversioned") do
148+
unversioned: Cask::Cask.new("test_unversioned") do
139149
version "1.2.3"
140150
sha256 :no_check
141151

@@ -144,7 +154,7 @@
144154
desc "Unversioned test cask"
145155
homepage "https://brew.sh"
146156
end,
147-
skip: Cask::Cask.new("test_skip") do
157+
skip: Cask::Cask.new("test_skip") do
148158
version "0.0.1"
149159

150160
url "https://brew.sh/test-0.0.1.tgz"
@@ -156,7 +166,7 @@
156166
skip
157167
end
158168
end,
159-
skip_with_message: Cask::Cask.new("test_skip_with_message") do
169+
skip_with_message: Cask::Cask.new("test_skip_with_message") do
160170
version "0.0.1"
161171

162172
url "https://brew.sh/test-0.0.1.tgz"
@@ -374,6 +384,12 @@
374384
end
375385
end
376386

387+
context "when a cask without a `livecheck` block is deprecated with a future disable date because `:unsigned`" do
388+
it "does not skip" do
389+
expect(skip_conditions.skip_information(casks[:future_disable_unsigned])).to eq({})
390+
end
391+
end
392+
377393
context "when a cask has a `livecheck` block using `ExtractPlist` and `--extract-plist` is not used" do
378394
it "skips" do
379395
expect(skip_conditions.skip_information(casks[:extract_plist], extract_plist: false))

0 commit comments

Comments
 (0)