Skip to content

Commit

Permalink
Store and use revision in tab runtime dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Oct 27, 2023
1 parent 832c424 commit 5455c64
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def installed?(minimum_version: nil)
return false unless formula

if minimum_version.present?
formula.any_version_installed? && (formula.any_installed_version.version >= minimum_version)
formula.any_version_installed? && (formula.any_installed_version >= minimum_version)
else
formula.latest_version_installed?
end
Expand Down
6 changes: 5 additions & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,14 @@ def expand_dependencies_for_formula(formula, inherited_options)
(formula.head? || !dependent.latest_version_installed?)

bottle_runtime_version = @bottle_tab_runtime_dependencies.dig(dep.name, "version")
bottle_runtime_revision = @bottle_tab_runtime_dependencies.dig(dep.name, "revision")

Check warning on line 620 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L620

Added line #L620 was not covered by tests
minimum_version = unless bottle_runtime_revision.nil?
PkgVersion.new(bottle_runtime_version, bottle_runtime_revision)
end

if dep.prune_from_option?(build) || ((dep.build? || dep.test?) && !keep_build_test)
Dependency.prune
elsif dep.satisfied?(inherited_options[dep.name], minimum_version: bottle_runtime_version)
elsif dep.satisfied?(inherited_options[dep.name], minimum_version: minimum_version)
Dependency.skip
end
end
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def self.runtime_deps_hash(formula, deps)
{
"full_name" => f.full_name,
"version" => f.version.to_s,
"revision" => f.revision,
"declared_directly" => formula.deps.include?(dep),
}
end
Expand Down
7 changes: 4 additions & 3 deletions Library/Homebrew/test/tab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
tab.homebrew_version = "1.1.6"
tab.runtime_dependencies = runtime_deps_hash
expect(tab.runtime_dependencies).to eql(
[{ "full_name" => "foo", "version" => "1.0", "declared_directly" => false }],
[{ "full_name" => "foo", "version" => "1.0", "revision" => 0, "declared_directly" => false }],
)
end

Expand Down Expand Up @@ -255,6 +255,7 @@
tap = Tap.new("user", "repo")
from_tap = formula("from_tap", path: tap.path/"Formula/from_tap.rb") do
url "from_tap-1.0"
revision 1
end
stub_formula_loader from_tap

Expand All @@ -266,8 +267,8 @@
tab = described_class.create(f, compiler, stdlib)

runtime_dependencies = [
{ "full_name" => "bar", "version" => "2.0", "declared_directly" => true },
{ "full_name" => "user/repo/from_tap", "version" => "1.0", "declared_directly" => true },
{ "full_name" => "bar", "version" => "2.0", "revision" => 0, "declared_directly" => true },
{ "full_name" => "user/repo/from_tap", "version" => "1.0", "revision" => 1, "declared_directly" => true },
]
expect(tab.runtime_dependencies).to eq(runtime_dependencies)

Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def upgrade_formulae(
nil
end
next true unless installed_version
next true if hash["revision"].nil? # Tabs prior to 4.1.18 did not have this

Version.new(hash["version"]) > installed_version.version
PkgVersion.new(hash["version"], hash["revision"]) > installed_version

Check warning on line 86 in Library/Homebrew/upgrade.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/upgrade.rb#L86

Added line #L86 was not covered by tests
end

fi.fetch
Expand Down

0 comments on commit 5455c64

Please sign in to comment.