Skip to content

Commit

Permalink
Remove arch and macos dependencies from cask tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylan12 committed Jul 10, 2024
1 parent fbe422b commit fec8454
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
7 changes: 2 additions & 5 deletions Library/Homebrew/cask/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.create(cask)

tab.tabfile = cask.metadata_main_container_path/FILENAME
tab.uninstall_flight_blocks = cask.uninstall_flight_blocks?
tab.runtime_dependencies = Tab.runtime_deps_hash(cask, cask.depends_on)
tab.runtime_dependencies = Tab.runtime_deps_hash(cask)
tab.source["version"] = cask.version.to_s
tab.source["path"] = cask.sourcefile_path.to_s
tab.uninstall_artifacts = cask.artifacts_list(uninstall_only: true)
Expand Down Expand Up @@ -49,7 +49,7 @@ def self.empty
tab
end

def self.runtime_deps_hash(cask, depends_on)
def self.runtime_deps_hash(cask)
cask_and_formula_dep_graph = ::Utils::TopologicalHash.graph_package_dependencies(cask)
cask_deps, formula_deps = cask_and_formula_dep_graph.values.flatten.uniq.partition do |dep|
dep.is_a?(Cask)
Expand All @@ -73,9 +73,6 @@ def self.runtime_deps_hash(cask, depends_on)
end
end

runtime_deps[:macos] = depends_on.macos if depends_on.macos
runtime_deps[:arch] = depends_on.arch if depends_on.arch

runtime_deps
end

Expand Down
32 changes: 9 additions & 23 deletions Library/Homebrew/test/cask/tab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
specify "with no dependencies" do
cask = Cask::CaskLoader.load("local-transmission")

expect(described_class.runtime_deps_hash(cask, cask.depends_on)).to eq({})
expect(described_class.runtime_deps_hash(cask)).to eq({})
end

specify "with cask dependencies" do
Expand All @@ -100,37 +100,25 @@
{ "full_name"=>"local-transmission", "version"=>"2.61", "declared_directly"=>true },
],
}
expect(described_class.runtime_deps_hash(cask, cask.depends_on)).to eq(expected_hash)
expect(described_class.runtime_deps_hash(cask)).to eq(expected_hash)
end

specify "with macos symbol dependencies" do
it "ignores macos symbol dependencies" do
cask = Cask::CaskLoader.load("with-depends-on-macos-symbol")

expected_hash = {
macos: MacOSRequirement.new([MacOS.version.to_sym], comparator: "=="),
}
expect(described_class.runtime_deps_hash(cask, cask.depends_on)).to eq(expected_hash)
expect(described_class.runtime_deps_hash(cask)).to eq({})
end

specify "with macos array dependencies" do
it "ignores macos array dependencies" do
cask = Cask::CaskLoader.load("with-depends-on-macos-array")

expected_hash = {
macos: MacOSRequirement.new([[:catalina, MacOS.version.to_sym]], comparator: "=="),
}
expect(described_class.runtime_deps_hash(cask, cask.depends_on)).to eq(expected_hash)
expect(described_class.runtime_deps_hash(cask)).to eq({})
end

specify "with arch dependencies" do
it "ignores arch dependencies" do
cask = Cask::CaskLoader.load("with-depends-on-arch")

expected_hash = {
arch: [
{ type: :intel, bits: 64 },
{ type: :arm, bits: 64 },
],
}
expect(described_class.runtime_deps_hash(cask, cask.depends_on)).to eq(expected_hash)
expect(described_class.runtime_deps_hash(cask)).to eq({})
end

specify "with all types of dependencies" do
Expand All @@ -141,7 +129,6 @@
expect(Formulary).to receive(:factory).with("unar").and_return(unar)

expected_hash = {
arch: [{ type: :intel, bits: 64 }, { type: :arm, bits: 64 }],
cask: [
{ "full_name"=>"local-caffeine", "version"=>"1.2.3", "declared_directly"=>true },
{ "full_name"=>"with-depends-on-cask", "version"=>"1.2.3", "declared_directly"=>true },
Expand All @@ -150,10 +137,9 @@
formula: [
{ "full_name"=>"unar", "version"=>"1.2", "revision"=>0, "pkg_version"=>"1.2", "declared_directly"=>true },
],
macos: MacOSRequirement.new([:el_capitan], comparator: ">="),
}

runtime_deps_hash = described_class.runtime_deps_hash(cask, cask.depends_on)
runtime_deps_hash = described_class.runtime_deps_hash(cask)
tab = described_class.new
tab.runtime_dependencies = runtime_deps_hash
expect(tab.runtime_dependencies).to eql(expected_hash)
Expand Down

0 comments on commit fec8454

Please sign in to comment.