uninstall: exclude configurational filess that belong to other formulae

Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
botantony 2025-05-16 10:13:40 +02:00
parent e4e75f5474
commit 3dad44c9f3
No known key found for this signature in database
GPG Key ID: 7FE721557EA6AAD6

View File

@ -67,7 +67,18 @@ module Homebrew
end
unversioned_name = f.name.gsub(/@.+$/, "")
maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*")
maybe_paths = Dir.glob("#{f.etc}/#{unversioned_name}*")
excluded_names = Homebrew::API::Formula.all_formulae.keys
maybe_paths = maybe_paths.reject do |path|
# Remove extension only if a file
# (f.e. directory with name "openssl@1.1" will be trimmed to "openssl@1")
filename = if File.directory?(path)
File.basename(path)
else
File.basename(path, ".*")
end
excluded_names.include?(filename)
end
maybe_paths -= paths if paths.present?
if maybe_paths.present?
puts