Skip to content

Commit 868dfb6

Browse files
committed
info: change disabled dates
- Remove useless REMOVE_DISABLED_BEFORE - Add deprecated_period attribute to be able to finetune the disable date - This new attribute is set to :long by default to be backward compatible - This will allow to write an automated script that will disable the formula after the right amount of time This also fixes the issue that the disabled date displayed in brew info right now is way to far in the future (1 year) instead of 6 months (either it's a bug or the code does not aligne with the doc)
1 parent 587949b commit 868dfb6

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

Library/Homebrew/cask/cask.rbi

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module Cask
2626

2727
def deprecation_reason; end
2828

29+
def deprecation_period; end
30+
2931
def disabled?; end
3032

3133
def disable_date; end

Library/Homebrew/cask/dsl.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class DSL
8787
:deprecated?,
8888
:deprecation_date,
8989
:deprecation_reason,
90+
:deprecation_period,
9091
:disable!,
9192
:disabled?,
9293
:disable_date,
@@ -105,7 +106,13 @@ class DSL
105106
extend Attrable
106107
include OnSystem::MacOSOnly
107108

108-
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :disable_date, :disable_reason,
109+
attr_reader :cask,
110+
:token,
111+
:deprecation_date,
112+
:deprecation_reason,
113+
:disable_date,
114+
:disable_reason,
115+
:deprecation_period,
109116
:on_system_block_min_os
110117

111118
attr_predicate :deprecated?, :disabled?, :livecheckable?, :on_system_blocks_exist?, :depends_on_set_in_block?
@@ -442,10 +449,11 @@ def livecheck(&block)
442449
# NOTE: A warning will be shown when trying to install this cask.
443450
#
444451
# @api public
445-
def deprecate!(date:, because:)
452+
def deprecate!(date:, because:, deprecation_period: :long)
446453
@deprecation_date = Date.parse(date)
447454
return if @deprecation_date > Date.today
448455

456+
@deprecation_period = deprecation_period
449457
@deprecation_reason = because
450458
@deprecated = true
451459
end
@@ -455,11 +463,12 @@ def deprecate!(date:, because:)
455463
# NOTE: An error will be thrown when trying to install this cask.
456464
#
457465
# @api public
458-
def disable!(date:, because:)
466+
def disable!(date:, because:, deprecation_period:)
459467
@disable_date = Date.parse(date)
460468

461469
if @disable_date > Date.today
462470
@deprecation_reason = because
471+
@deprecation_period = deprecation_period
463472
@deprecated = true
464473
return
465474
end

Library/Homebrew/deprecate_disable.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ module DeprecateDisable
3030
unsigned: "is unsigned or does not meet signature requirements",
3131
}.freeze
3232

33+
DEPRECATE_PERIOD_MONTHS = {
34+
short: 1,
35+
long: 6,
36+
}.freeze
37+
3338
# One year when << or >> to Date.today.
3439
REMOVE_DISABLED_TIME_WINDOW = 12
35-
REMOVE_DISABLED_BEFORE = (Date.today << REMOVE_DISABLED_TIME_WINDOW).freeze
3640

3741
def type(formula_or_cask)
3842
return :deprecated if formula_or_cask.deprecated?
@@ -65,7 +69,8 @@ def message(formula_or_cask)
6569

6670
disable_date = formula_or_cask.disable_date
6771
if !disable_date && formula_or_cask.deprecation_date
68-
disable_date = formula_or_cask.deprecation_date >> REMOVE_DISABLED_TIME_WINDOW
72+
period = DEPRECATE_PERIOD_MONTHS[formula_or_cask.deprecation_period]
73+
disable_date = formula_or_cask.deprecation_date >> period
6974
end
7075
if disable_date
7176
message += if disable_date < Date.today

Library/Homebrew/formula.rb

+16-1
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,13 @@ def link_overwrite?(path)
15361536
# @see .deprecate!
15371537
delegate deprecation_reason: :"self.class"
15381538

1539+
# The time before the {Formula} becomes disabled
1540+
# Returns `nil` if no date is specified.
1541+
# @!method deprecation_period
1542+
# @return [String, Symbol]
1543+
# @see .deprecate!
1544+
delegate deprecation_period: :"self.class"
1545+
15391546
# Whether this {Formula} is disabled (i.e. cannot be installed).
15401547
# Defaults to false.
15411548
# @!method disabled?
@@ -4225,10 +4232,11 @@ def pour_bottle?(only_if: nil, &block)
42254232
# @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae
42264233
# @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
42274234
# @api public
4228-
def deprecate!(date:, because:)
4235+
def deprecate!(date:, because:, deprecation_period: :long)
42294236
@deprecation_date = Date.parse(date)
42304237
return if @deprecation_date > Date.today
42314238

4239+
@deprecation_period = deprecation_period
42324240
@deprecation_reason = because
42334241
@deprecated = true
42344242
end
@@ -4255,6 +4263,13 @@ def deprecated?
42554263
# @see .deprecate!
42564264
attr_reader :deprecation_reason
42574265

4266+
# The time before the {Formula} becomes disabled.
4267+
#
4268+
# @return [nil] if no reason was provided or the formula is not deprecated.
4269+
# @return [String, Symbol]
4270+
# @see .deprecate!
4271+
attr_reader :deprecation_period
4272+
42584273
# Disables a {Formula} (on the given date) so it cannot be
42594274
# installed. If the date has not yet passed the formula
42604275
# will be deprecated instead of disabled.

docs/Deprecating-Disabling-and-Removing-Formulae.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ Formulae with dependents should not be deprecated until or when all dependents a
3030
To deprecate a formula, add a `deprecate!` call. This call should include a deprecation date (in the ISO 8601 format) and a deprecation reason:
3131

3232
```ruby
33-
deprecate! date: "YYYY-MM-DD", because: :reason
33+
deprecate! date: "YYYY-MM-DD", because: :reason, deprecation_period: :short
3434
```
3535

3636
The `date` parameter should be set to the date that the deprecation period should begin, which is usually today's date. If the `date` parameter is set to a date in the future, the formula will not become deprecated until that date. This can be useful if the upstream developers have indicated a date when the project or version will stop being supported. Do not backdate the `date` parameter as it causes confusion for users and maintainers.
3737

3838
The `because` parameter can be a preset reason (using a symbol) or a custom reason. See the [Deprecate and Disable Reasons](#deprecate-and-disable-reasons) section below for more details about the `because` parameter.
3939

40+
The `deprecation_period:` can be either :short or :long (1 or 6 months). After this period a formula should be disabled.
41+
4042
## Disabling
4143

4244
If a user attempts to install a disabled formula, they will be shown an error message and the install will fail.
@@ -49,10 +51,9 @@ The most common reasons for disabling a formula are:
4951
- it has been deprecated for a long time
5052
- the project has no license
5153

52-
Popular formulae (e.g. have more than 1000 [analytics installs in the last 90 days](https://formulae.brew.sh/analytics/install/90d/)) should not be disabled without a deprecation period of at least six months even if e.g. they do not build from source and do not have a license.
54+
Popular formulae (e.g. have more than 1000 [analytics installs in the last 90 days](https://formulae.brew.sh/analytics/install/90d/)) should not be disabled without a deprecation period of six months even if e.g. they do not build from source and do not have a license.
5355

54-
Unpopular formulae (e.g. have fewer than 1000 [analytics installs in the last 90 days](https://formulae.brew.sh/analytics/install/90d/)) can be disabled immediately for any of the reasons above e.g. they cannot be built from source on any supported macOS version or Linux.
55-
They can be manually removed three months after their disable date.
56+
Unpopular formulae (e.g. have fewer than 1000 [analytics installs in the last 90 days](https://formulae.brew.sh/analytics/install/90d/)) can be disabled after one month for any of the reasons above e.g. they cannot be built from source on any supported macOS version or Linux.
5657

5758
To disable a formula, add a `disable!` call. This call should include a deprecation date in the ISO 8601 format and a deprecation reason:
5859

0 commit comments

Comments
 (0)