diff options
| author | Alyssa Ross | 2016-09-19 01:53:48 +0100 |
|---|---|---|
| committer | Alyssa Ross | 2016-09-19 02:08:42 +0100 |
| commit | 6ec14288aa727eeb3d3a7773720695394697a62a (patch) | |
| tree | 4a745d261490f3c8b83a142f6ae8a9c15b5a5000 /Library | |
| parent | 4abd48812bb544426442749266acb13a20ce434c (diff) | |
| download | brew-6ec14288aa727eeb3d3a7773720695394697a62a.tar.bz2 | |
Formulae aren't outdated if replacement formula installed
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 795646d08..238c6c4bc 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1139,7 +1139,9 @@ class Formula tab = Tab.for_keg(keg) next if version_scheme > tab.version_scheme next if version_scheme == tab.version_scheme && pkg_version > version - next if follow_installed_alias? && installed_alias_target_changed? + + # don't consider this keg current if there's a newer formula available + next if follow_installed_alias? && new_formula_available? return [] # this keg is the current version of the formula, so it's not outdated end @@ -1157,6 +1159,10 @@ class Formula end end + def new_formula_available? + installed_alias_target_changed? && !latest_formula.installed? + end + def current_installed_alias_target Formulary.factory(installed_alias_path) if installed_alias_path end diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 3a021b4f6..9f39dd2d0 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -851,7 +851,7 @@ class OutdatedVersionsTests < Homebrew::TestCase :greater_prefix, :head_prefix, :old_alias_target_prefix - attr_reader :f, :old_formula + attr_reader :f, :old_formula, :new_formula def setup @f = formula do @@ -860,6 +860,7 @@ class OutdatedVersionsTests < Homebrew::TestCase end @old_formula = formula("foo@1") { url "foo-1.0" } + @new_formula = formula("foo@2") { url "foo-2.0" } @outdated_prefix = HOMEBREW_CELLAR/"#{f.name}/1.11" @same_prefix = HOMEBREW_CELLAR/"#{f.name}/1.20" @@ -869,7 +870,8 @@ class OutdatedVersionsTests < Homebrew::TestCase end def teardown - [@f.rack, @old_formula.rack].select(&:exist?).each(&:rmtree) + formulae = [@f, @old_formula, @new_formula] + formulae.map(&:rack).select(&:exist?).each(&:rmtree) end def alias_path @@ -921,13 +923,21 @@ class OutdatedVersionsTests < Homebrew::TestCase assert_predicate f.outdated_kegs, :empty? end - def test_outdated_follow_alias_and_alias_changed + def test_outdated_follow_alias_and_alias_changed_and_new_target_not_installed f.follow_installed_alias = true f.build = setup_tab_for_prefix(same_prefix, path: alias_path) - stub_formula_loader(formula("foo@2") { url "foo-2.0" }, alias_path) + stub_formula_loader(new_formula, alias_path) refute_predicate f.outdated_kegs, :empty? end + def test_outdated_follow_alias_and_alias_changed_and_new_target_installed + f.follow_installed_alias = true + f.build = setup_tab_for_prefix(same_prefix, path: alias_path) + stub_formula_loader(new_formula, alias_path) + setup_tab_for_prefix(new_formula.prefix) # install new_formula + assert_predicate f.outdated_kegs, :empty? + end + def test_outdated_no_follow_alias_and_alias_unchanged f.follow_installed_alias = false f.build = setup_tab_for_prefix(same_prefix, path: alias_path) |
