reinstall: move to submodule

This commit is contained in:
Bo Anderson 2024-08-20 03:58:01 +01:00
parent 561cc17a74
commit 77204e01da
No known key found for this signature in database
3 changed files with 91 additions and 88 deletions

View File

@ -134,7 +134,7 @@ module Homebrew
next
end
Migrator.migrate_if_needed(formula, force: args.force?)
Homebrew.reinstall_formula(
Homebrew::Reinstall.reinstall_formula(
formula,
flags: args.flags_only,
installed_on_request: args.named.present?,

View File

@ -6,9 +6,8 @@ require "development_tools"
require "messages"
module Homebrew
module_function
def reinstall_formula(
module Reinstall
def self.reinstall_formula(
formula,
flags:,
installed_on_request: false,
@ -79,7 +78,7 @@ module Homebrew
end
end
def backup(keg)
def self.backup(keg)
keg.unlink
begin
keg.rename backup_path(keg)
@ -90,8 +89,9 @@ module Homebrew
EOS
end
end
private_class_method :backup
def restore_backup(keg, keg_was_linked, verbose:)
def self.restore_backup(keg, keg_was_linked, verbose:)
path = backup_path(keg)
return unless path.directory?
@ -101,8 +101,11 @@ module Homebrew
path.rename keg
keg.link(verbose:) if keg_was_linked
end
private_class_method :restore_backup
def backup_path(path)
def self.backup_path(path)
Pathname.new "#{path}.reinstall"
end
private_class_method :backup_path
end
end

View File

@ -409,7 +409,7 @@ module Homebrew
return if dry_run
reinstallable_broken_dependents.each do |formula|
Homebrew.reinstall_formula(
Reinstall.reinstall_formula(
formula,
flags:,
force_bottle:,