From 8c32bd7beb5dc6f2821f436dd4823c77ab1db1eb Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Tue, 14 Nov 2023 16:46:53 +0000 Subject: [PATCH] Don't reinstall dependency when latest already installed --- Library/Homebrew/dependency.rb | 34 +++++++++++++++++----------------- Library/Homebrew/upgrade.rb | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 15e50ab335ab70..c1e8780e865859 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -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 diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index 04c9bee2fb14f4..2541bd376d7130 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -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