Skip to content

Commit

Permalink
Support link_overwrite and conflicts_with in API
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Feb 20, 2023
1 parent 6b7ecd1 commit cacd719
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Library/Homebrew/formula.rb
Expand Up @@ -2119,6 +2119,8 @@ def to_hash
"uses_from_macos" => uses_from_macos_elements.uniq,
"requirements" => [],
"conflicts_with" => conflicts.map(&:name),
"conflicts_with_reasons" => conflicts.map(&:reason),
"link_overwrite" => self.class.link_overwrite_paths.to_a,
"caveats" => caveats&.gsub(HOMEBREW_PREFIX, HOMEBREW_PREFIX_PLACEHOLDER),
"installed" => [],
"linked_keg" => linked_version&.to_s,
Expand Down
8 changes: 8 additions & 0 deletions Library/Homebrew/formulary.rb
Expand Up @@ -244,6 +244,14 @@ def self.load_formula_from_api(name, flags:)
depends_on req_name => req_tags
end

json_formula["conflicts_with"].each_with_index do |conflict, index|
conflicts_with conflict, because: json_formula.dig("conflicts_with_reasons", index)
end

json_formula["link_overwrite"]&.each do |overwrite_path|
link_overwrite overwrite_path
end

def install
raise "Cannot build from source from abstract formula."
end
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/test/formulary_spec.rb
Expand Up @@ -253,6 +253,9 @@ def formula_json_contents(extra_items = {})
"contexts" => ["build"],
},
],
"conflicts_with" => ["conflicting_formula"],
"conflicts_with_reasons" => ["it does"],
"link_overwrite" => ["bin/abc"],
"caveats" => "example caveat string",
}.merge(extra_items),
}
Expand Down Expand Up @@ -330,6 +333,10 @@ def formula_json_contents(extra_items = {})
expect(req.version).to eq "1.0"
expect(req.tags).to eq [:build]

expect(formula.conflicts.map(&:name)).to include "conflicting_formula"
expect(formula.conflicts.map(&:reason)).to include "it does"
expect(formula.class.link_overwrite_paths).to include "bin/abc"

expect(formula.caveats).to eq "example caveat string"

expect {
Expand Down

0 comments on commit cacd719

Please sign in to comment.