Merge pull request #864 from vladshablinsky/skip-upgrade
Skip upgrade of pinned dependency if it's outdated
This commit is contained in:
commit
f37d004ab5
@ -8,7 +8,13 @@ module Homebrew
|
||||
def reinstall
|
||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
||||
|
||||
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
|
||||
ARGV.resolved_formulae.each do |f|
|
||||
if f.pinned?
|
||||
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
||||
next
|
||||
end
|
||||
reinstall_formula(f)
|
||||
end
|
||||
end
|
||||
|
||||
def reinstall_formula(f)
|
||||
|
@ -146,11 +146,21 @@ class FormulaInstaller
|
||||
raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula)
|
||||
|
||||
unless skip_deps_check?
|
||||
unlinked_deps = formula.recursive_dependencies.map(&:to_formula).select do |dep|
|
||||
recursive_deps = formula.recursive_dependencies
|
||||
unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
|
||||
dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
|
||||
end
|
||||
raise CannotInstallFormulaError,
|
||||
"You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" unless unlinked_deps.empty?
|
||||
|
||||
pinned_unsatisfied_deps = recursive_deps.select do |dep|
|
||||
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
|
||||
end
|
||||
|
||||
unless pinned_unsatisfied_deps.empty?
|
||||
raise CannotInstallFormulaError,
|
||||
"You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -491,6 +491,31 @@ class FormulaTests < Homebrew::TestCase
|
||||
f3.rack.rmtree
|
||||
end
|
||||
|
||||
def test_eligible_kegs_for_cleanup_keg_pinned
|
||||
f1 = Class.new(Testball) { version "0.1" }.new
|
||||
f2 = Class.new(Testball) { version "0.2" }.new
|
||||
f3 = Class.new(Testball) { version "0.3" }.new
|
||||
|
||||
shutup do
|
||||
f1.brew { f1.install }
|
||||
f1.pin
|
||||
f2.brew { f2.install }
|
||||
f3.brew { f3.install }
|
||||
end
|
||||
|
||||
assert_equal HOMEBREW_LIBRARY.join("PinnedKegs/#{f1.name}").resolved_path, f1.prefix
|
||||
|
||||
assert_predicate f1, :installed?
|
||||
assert_predicate f2, :installed?
|
||||
assert_predicate f3, :installed?
|
||||
|
||||
assert_equal [Keg.new(f2.prefix)], shutup { f3.eligible_kegs_for_cleanup }
|
||||
ensure
|
||||
f1.unpin
|
||||
[f1, f2, f3].each(&:clear_cache)
|
||||
f3.rack.rmtree
|
||||
end
|
||||
|
||||
def test_eligible_kegs_for_cleanup_head_installed
|
||||
f = formula do
|
||||
version "0.1"
|
||||
|
@ -92,3 +92,45 @@ class InstallTests < Homebrew::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class FormulaInstallerTests < Homebrew::TestCase
|
||||
def test_check_install_sanity_pinned_dep
|
||||
dep_name = "dependency"
|
||||
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
||||
dep_path.write <<-EOS.undent
|
||||
class #{Formulary.class_s(dep_name)} < Formula
|
||||
url "foo"
|
||||
version "0.2"
|
||||
end
|
||||
EOS
|
||||
|
||||
Formulary::FORMULAE.delete(dep_path)
|
||||
dependency = Formulary.factory(dep_name)
|
||||
|
||||
dependent = formula do
|
||||
url "foo"
|
||||
version "0.5"
|
||||
depends_on "#{dependency.name}"
|
||||
end
|
||||
|
||||
dependency.prefix("0.1").join("bin/a").mkpath
|
||||
HOMEBREW_LIBRARY.join("PinnedKegs").mkpath
|
||||
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_LIBRARY.join("PinnedKegs/#{dep_name}")
|
||||
|
||||
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
||||
dependency_keg.link
|
||||
|
||||
assert_predicate dependency_keg, :linked?
|
||||
assert_predicate dependency, :pinned?
|
||||
|
||||
fi = FormulaInstaller.new(dependent)
|
||||
assert_raises(CannotInstallFormulaError) { fi.check_install_sanity }
|
||||
ensure
|
||||
dependency.unpin
|
||||
dependency_keg.unlink
|
||||
dependency_keg.uninstall
|
||||
dependency.clear_cache
|
||||
dep_path.unlink
|
||||
Formulary::FORMULAE.delete(dep_path)
|
||||
end
|
||||
end
|
||||
|
@ -529,6 +529,18 @@ class IntegrationCommandTests < Homebrew::TestCase
|
||||
assert foo_dir.exist?
|
||||
end
|
||||
|
||||
def test_reinstall_pinned
|
||||
setup_test_formula "testball"
|
||||
|
||||
HOMEBREW_CELLAR.join("testball/0.1").mkpath
|
||||
HOMEBREW_LIBRARY.join("PinnedKegs").mkpath
|
||||
FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_LIBRARY.join("PinnedKegs/testball")
|
||||
|
||||
assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball")
|
||||
|
||||
HOMEBREW_LIBRARY.join("PinnedKegs").rmtree
|
||||
end
|
||||
|
||||
def test_home
|
||||
setup_test_formula "testball"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user