Cache outdated_versions for Formula
Closes #584. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
9754dbada8
commit
072e5df4ed
@ -1001,10 +1001,15 @@ class Formula
|
||||
|
||||
# @private
|
||||
def outdated_versions(options = {})
|
||||
@outdated_versions ||= begin
|
||||
all_versions = []
|
||||
|
||||
@outdated_versions ||= Hash.new do |cache, key|
|
||||
raise Migrator::MigrationNeededError.new(self) if migration_needed?
|
||||
cache[key] = _outdated_versions(key)
|
||||
end
|
||||
@outdated_versions[options]
|
||||
end
|
||||
|
||||
def _outdated_versions(options = {})
|
||||
all_versions = []
|
||||
|
||||
installed_kegs.each do |keg|
|
||||
version = keg.version
|
||||
@ -1014,11 +1019,10 @@ class Formula
|
||||
end
|
||||
|
||||
head_version = latest_head_version
|
||||
if head_version
|
||||
head_version_outdated?(head_version, options) ? all_versions.sort! : []
|
||||
if head_version && !head_version_outdated?(head_version, options)
|
||||
[]
|
||||
else
|
||||
all_versions.sort!
|
||||
end
|
||||
all_versions.sort
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -583,6 +583,7 @@ class OutdatedVersionsTests < Homebrew::TestCase
|
||||
|
||||
def reset_outdated_versions
|
||||
f.instance_variable_set(:@outdated_versions, nil)
|
||||
f.instance_variable_set(:@outdated_versions_head_fetched, nil)
|
||||
end
|
||||
|
||||
def test_greater_different_tap_installed
|
||||
|
Loading…
x
Reference in New Issue
Block a user