Skip to content

formula: dedupe link_overwrite_formulae across aliases#22046

Merged
MikeMcQuaid merged 1 commit intomainfrom
fix/link-overwrite-reason-dedup
Apr 20, 2026
Merged

formula: dedupe link_overwrite_formulae across aliases#22046
MikeMcQuaid merged 1 commit intomainfrom
fix/link-overwrite-reason-dedup

Conversation

@p-linnane
Copy link
Copy Markdown
Member


  • 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? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration 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. Non-maintainers may only have one AI-assisted/generated PR open at a time.

Claude Code Opus 4.7 was used to create the test.


When I installed openssl@4 today, I was presented with this warning:

Warning: openssl@4 was installed but not linked because openssl@3 and openssl@3 are already linked.

After this change:

Warning: openssl@4 was installed but not linked because openssl@3 is already linked.

Formula#link_overwrite_formulae_names can include both an alias (openssl) and its canonical name (openssl@3) as distinct strings that resolve to the same Formula via Formula[], so the sentence ends up listing it twice. Dedupe by full_name after resolving names to formulae.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI review requested due to automatic review settings April 19, 2026 18:25
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

This PR fixes duplicated entries in Formula#link_overwrite_reason warnings when link_overwrite_formulae_names contains both an alias and a canonical name that resolve to the same formula, by deduplicating after resolution.

Changes:

  • Deduplicate link_overwrite_formulae results by full_name after resolving names to Formula instances.
  • Add a unit test asserting alias/canonical-name resolution does not produce duplicate formulae in link_overwrite_formulae.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/formula.rb Dedupes resolved overwrite formulae via uniq(&:full_name) to prevent duplicate warnings.
Library/Homebrew/test/formula_spec.rb Adds a regression test for deduplication when alias and canonical names map to the same formula.

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

Copy link
Copy Markdown
Member

@ZhongRuoyu ZhongRuoyu left a comment

Choose a reason for hiding this comment

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

Thanks!

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!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit 2983f2e Apr 20, 2026
40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix/link-overwrite-reason-dedup branch April 20, 2026 08:21
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.

4 participants