Merge pull request #20446 from Homebrew/copilot/fix-20427
Fix `brew upgrade` not linking newer versions when upgrade interrupted
This commit is contained in:
commit
0d4f3419ac
@ -1681,7 +1681,10 @@ class Formula
|
|||||||
# don't consider this keg current if there's a newer formula available
|
# don't consider this keg current if there's a newer formula available
|
||||||
next if follow_installed_alias? && new_formula_available?
|
next if follow_installed_alias? && new_formula_available?
|
||||||
|
|
||||||
# this keg is the current version of the formula, so it's not outdated
|
# this keg is the current version of the formula, but only consider it current
|
||||||
|
# if it's actually linked - an unlinked current version means we're outdated
|
||||||
|
next if !keg.optlinked? && !keg.linked? && !pinned?
|
||||||
|
|
||||||
current_version = true
|
current_version = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -18,6 +18,18 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
|
|||||||
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "links newer version when upgrade was interrupted", :integration_test do
|
||||||
|
setup_test_formula "testball"
|
||||||
|
|
||||||
|
(HOMEBREW_CELLAR/"testball/0.1/foo").mkpath
|
||||||
|
|
||||||
|
expect { brew "upgrade" }.to be_a_success
|
||||||
|
|
||||||
|
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
|
||||||
|
expect(HOMEBREW_PREFIX/"opt/testball").to be_a_symlink
|
||||||
|
expect(HOMEBREW_PREFIX/"var/homebrew/linked/testball").to be_a_symlink
|
||||||
|
end
|
||||||
|
|
||||||
it "upgrades with asking for user prompts", :integration_test do
|
it "upgrades with asking for user prompts", :integration_test do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
|
@ -1364,6 +1364,10 @@ RSpec.describe Formula do
|
|||||||
|
|
||||||
def setup_tab_for_prefix(prefix, options = {})
|
def setup_tab_for_prefix(prefix, options = {})
|
||||||
prefix.mkpath
|
prefix.mkpath
|
||||||
|
|
||||||
|
keg = Keg.new(prefix)
|
||||||
|
keg.optlink
|
||||||
|
|
||||||
tab = Tab.empty
|
tab = Tab.empty
|
||||||
tab.tabfile = prefix/AbstractTab::FILENAME
|
tab.tabfile = prefix/AbstractTab::FILENAME
|
||||||
tab.source["path"] = options[:path].to_s if options[:path]
|
tab.source["path"] = options[:path].to_s if options[:path]
|
||||||
@ -1396,6 +1400,12 @@ RSpec.describe Formula do
|
|||||||
expect(f.outdated_kegs).not_to be_empty
|
expect(f.outdated_kegs).not_to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
example "outdated unlinked tap installed" do
|
||||||
|
setup_tab_for_prefix(same_prefix)
|
||||||
|
Keg.new(same_prefix).remove_opt_record
|
||||||
|
expect(f.outdated_kegs).not_to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
example "outdated follow alias and alias unchanged" do
|
example "outdated follow alias and alias unchanged" do
|
||||||
f.follow_installed_alias = true
|
f.follow_installed_alias = true
|
||||||
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
|
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user