Skip to content

Commit

Permalink
Don't reinstall dependency when latest already installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Nov 14, 2023
1 parent 75e8376 commit 8c32bd7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Library/Homebrew/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ def installed?(minimum_version: nil, minimum_revision: nil)
end
return false unless formula

if minimum_version.present?
installed_version = formula.any_installed_version
return false unless installed_version

# Tabs prior to 4.1.18 did not have revision or pkg_version fields.
# As a result, we have to be more conversative when we do not have
# a minimum revision from the tab and assume that if the formula has a
# the same version and a non-zero revision that it needs upgraded.
if minimum_revision.present?
minimum_pkg_version = PkgVersion.new(minimum_version, minimum_revision)
installed_version >= minimum_pkg_version
elsif installed_version.version == minimum_version
formula.revision.zero?
else
installed_version.version > minimum_version
end
return true if formula.latest_version_installed?

return false if minimum_version.blank?

installed_version = formula.any_installed_version
return false unless installed_version

# Tabs prior to 4.1.18 did not have revision or pkg_version fields.
# As a result, we have to be more conversative when we do not have
# a minimum revision from the tab and assume that if the formula has a
# the same version and a non-zero revision that it needs upgraded.
if minimum_revision.present?
minimum_pkg_version = PkgVersion.new(minimum_version, minimum_revision)
installed_version >= minimum_pkg_version
elsif installed_version.version == minimum_version
formula.revision.zero?
else
formula.latest_version_installed?
installed_version.version > minimum_version
end
end

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def upgrade_formulae(
end
next false if dependency_formula.nil?

next true if dependency_formula.latest_version_installed?

installed_version = dependency_formula.any_installed_version
next false unless installed_version

Expand Down

0 comments on commit 8c32bd7

Please sign in to comment.