Combine dependency role tags from API metadata #24302

Merged
p-linnane opened 6:33am on October 20, 2026 wanted to merge 77 Ξ” into homebrew/brew main from
api-dependency-tag-union
Diff Delta:
77
About 43 Diff Delta/hour
Classified as:  General

p-linnane's Description of Work

Formulae loaded from the API split a dependency with more than one role, such as depends_on "foo" => [:build, :test], into separate :build and :test dependencies, while loading the formula's Ruby source keeps one Dependency with both tags. FormulaStructGenerator.process_dependencies now unions each name's role tags in a fixed order (:build, :test, :recommended, :optional, then :no_linkage) so API-loaded formulae get the same dependencies as source-loaded ones; separate :build and :test declarations of one name also load as one combined dependency. Runtime entries stay separate, so a formula that depends on gettext and also declares it :build keeps it in both dependencies and build_dependencies from Formula#to_hash. The round-trip examples now cover a runtime dependency with combined tags, compare the Formula#to_hash dependency lists and stub the API metadata Formula#to_hash reads so they run offline. Brew versions before 7.0.10 (#24262) reject array-valued tags in the internal API when HOMEBREW_SORBET_RUNTIME is set.



  • [x] Have you followed our Contributing guidelines?

  • [x] Have you checked for other open Pull Requests for the same change?

  • [x] Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.

  • [x] Have you explained why you'd like these changes included, not just what they do?

  • [ ] For bug fixes, have you given step-by-step brew commands to reproduce the bug?

  • [x] Have you written new tests (excluding integration tests)? Here's an example.

  • [x] Have you successfully run brew lgtm (style, typechecking and tests) locally?



  • [x] I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Codex (GPT-6 Astra) wrote the change and tests, compared source and API-loaded dependencies across homebrew/core for all 16 OS/arch tags, checked the new examples fail before the change on host and --generic and ran brew lgtm --online. Claude Code (Opus 5.5) reviewed it, found that an earlier version dropped runtime dependencies from the Formula#to_hash role lists, reran the comparison on the final version for the formulae whose output could change, checked the new examples fail on the previous code offline on host and --generic, rebased onto current main and ran brew lgtm --online on this commit.


Summary by CodeRabbit



  • Bug Fixes


    • Improved dependency metadata handling to remove duplicate entries and preserve all applicable dependency types.

    • Dependencies can now retain multiple tags, including build, test, recommended, optional, runtime and no-linkage classifications.

    • Dependency metadata round-trips now more reliably preserve these classifications and their ordering.



3 total changed files
Loading changes...
You are now leaving the Pull Request Diff Zone
Please mind the merge button