Skip to content

formula: restore using replacement from disable!#21678

Draft
cho-m wants to merge 1 commit intomainfrom
formula-restore-showing-replacement
Draft

formula: restore using replacement from disable!#21678
cho-m wants to merge 1 commit intomainfrom
formula-restore-showing-replacement

Conversation

@cho-m
Copy link
Copy Markdown
Member

@cho-m cho-m commented Mar 6, 2026

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Previous behavior before #21644

This allows providing a single replacement_formula: on the disable! stanza rather than duplicating it in both disable! and deprecate!

e.g.

deprecate! date: "2026-03-06", because: :unmaintained
disable! date: "2026-03-06", because: :unmaintained, replacement_formula: "foo"

Also remove some T.must and move some T.let to the simpler (nil) case for readability.

Previous behavior before #21644

This allows providing a single `replacement_formula:` on the `disable!`
stanza rather than duplicating it in both `disable!` and `deprecate!`.
Copilot AI review requested due to automatic review settings March 6, 2026 15:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Formula deprecation/disable metadata handling so disable! can supply replacement information used for deprecation (restoring behavior from before #21644), while also simplifying some Sorbet annotations for readability.

Changes:

  • Populate deprecation fields from disable! when disable! is in the future and deprecate! hasn’t set them.
  • Refactor deprecate!/disable! to reduce T.must usage and streamline T.let placement.
  • Adjust interaction between deprecate! and disable! when both stanzas are present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4797 to +4798
replacement_formula ||= replacement
replacement_cask ||= replacement
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in deprecate!: replacement_formula ||= replacement/replacement_cask ||= replacement won’t remap when replacement_formula/replacement_cask is "". Because blanks are treated as absent via .presence in the argument validation (and later when setting @disable_replacement_*), consider using .presence || replacement for the remap to avoid blank replacements being stored/propagated.

Suggested change
replacement_formula ||= replacement
replacement_cask ||= replacement
replacement_formula = replacement_formula.presence || replacement
replacement_cask = replacement_cask.presence || replacement

Copilot uses AI. Check for mistakes.
Comment on lines +4811 to +4815
# Use `disable!` information if not set in `deprecate!`
@deprecation_reason ||= because
@deprecation_replacement_formula ||= replacement_formula
@deprecation_replacement_cask ||= replacement_cask
@deprecated ||= true
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new disable!→deprecation propagation (@deprecation_* ||= ...) changes behavior when both deprecate! and a future disable! are present (e.g., deprecate has no replacement but disable does). There are existing specs for date ordering, but none cover this replacement propagation; please add an RSpec example asserting deprecation_replacement_formula/cask are populated from disable! when missing from deprecate! (in both stanza orders).

Copilot uses AI. Check for mistakes.
Comment on lines 4682 to +4684
if replacement
replacement_formula ||= replacement
replacement_cask ||= replacement
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacement_formula ||= replacement/replacement_cask ||= replacement doesn't treat blank strings as absent, but earlier validation uses .presence (so a blank value is effectively treated like nil). This can leave replacement_formula as "" and then set @deprecation_replacement_* to an empty string. Consider normalizing with .presence (and doing the legacy replacement remap using .presence || replacement) before using these values, so blanks don’t propagate into deprecation metadata/API output.

Copilot uses AI. Check for mistakes.
Comment on lines +4696 to +4698
@deprecation_reason = because if because
@deprecation_replacement_formula = replacement_formula if replacement_formula
@deprecation_replacement_cask = replacement_cask if replacement_cask
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the deprecated branch, @deprecation_replacement_formula = replacement_formula if replacement_formula will also accept an empty string (truthy) and persist it as the replacement. To match the .presence semantics used elsewhere in this method, consider assigning only replacement_formula.presence/replacement_cask.presence (or normalizing once up-front) so blank values don’t override or block fallback behavior.

Suggested change
@deprecation_reason = because if because
@deprecation_replacement_formula = replacement_formula if replacement_formula
@deprecation_replacement_cask = replacement_cask if replacement_cask
if (present_because = because.presence)
@deprecation_reason = present_because
end
if (present_replacement_formula = replacement_formula.presence)
@deprecation_replacement_formula = present_replacement_formula
end
if (present_replacement_cask = replacement_cask.presence)
@deprecation_replacement_cask = present_replacement_cask
end

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A comment from me and Copilot ones look worth considering.

Self-merge when happy.

if replacement
replacement_formula ||= replacement
replacement_cask ||= replacement
odeprecated(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments here and anywhere else that this odeprecated/odisabled should stay the same between releases 🙇🏻

@cho-m cho-m marked this pull request as draft March 20, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants