Skip to content

Commit e7d3ce9

Browse files
committed
formula: handle future deprecation and disable dates
1 parent 27ae838 commit e7d3ce9

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Library/Homebrew/formula.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4797,7 +4797,7 @@ def disable!(date:, because:, replacement: nil, replacement_formula: nil, replac
47974797
@deprecation_reason = T.let(because, T.nilable(T.any(String, Symbol)))
47984798
@deprecation_replacement_formula = T.let(replacement_formula.presence || replacement, T.nilable(String))
47994799
@deprecation_replacement_cask = T.let(replacement_cask.presence || replacement, T.nilable(String))
4800-
@deprecated = T.let(true, T.nilable(T::Boolean))
4800+
@deprecated = T.let(true, T.nilable(T::Boolean)) if @deprecation_date.nil?
48014801
return
48024802
end
48034803

Library/Homebrew/test/formula_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,4 +2053,44 @@ def install
20532053
expect(f.class.preserve_rpath?).to be(false)
20542054
end
20552055
end
2056+
2057+
describe "#deprecated?" do
2058+
let(:f) do
2059+
formula "foo" do
2060+
url "foo-1.0"
2061+
deprecate! date: "2020-01-01", because: :unmaintained
2062+
disable! date: "2021-01-01", because: :unmaintained
2063+
end
2064+
end
2065+
2066+
it "is false before deprecate date" do
2067+
allow(Date).to receive(:today).and_return(Date.parse("2019-01-01"))
2068+
expect(f.deprecated?).to be(false)
2069+
end
2070+
2071+
it "is true on deprecate date" do
2072+
allow(Date).to receive(:today).and_return(Date.parse("2020-01-01"))
2073+
expect(f.deprecated?).to be(true)
2074+
end
2075+
end
2076+
2077+
describe "#disabled?" do
2078+
let(:f) do
2079+
formula "foo" do
2080+
url "foo-1.0"
2081+
deprecate! date: "2020-01-01", because: :unmaintained
2082+
disable! date: "2021-01-01", because: :unmaintained
2083+
end
2084+
end
2085+
2086+
it "is false between deprecate and disable date" do
2087+
allow(Date).to receive(:today).and_return(Date.parse("2020-06-01"))
2088+
expect(f.disabled?).to be(false)
2089+
end
2090+
2091+
it "is true on disable date" do
2092+
allow(Date).to receive(:today).and_return(Date.parse("2021-01-01"))
2093+
expect(f.disabled?).to be(true)
2094+
end
2095+
end
20562096
end

0 commit comments

Comments
 (0)