From 3dad44c9f35c027aea06cb809a7f80decff787a6 Mon Sep 17 00:00:00 2001 From: botantony Date: Fri, 16 May 2025 10:13:40 +0200 Subject: [PATCH 1/2] uninstall: exclude configurational filess that belong to other formulae Signed-off-by: botantony --- Library/Homebrew/uninstall.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/uninstall.rb b/Library/Homebrew/uninstall.rb index ba03abc04f..206bb6cdbc 100644 --- a/Library/Homebrew/uninstall.rb +++ b/Library/Homebrew/uninstall.rb @@ -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 From 2f10b1cd6ee1ddfc976807bf881c23fc8c5b4579 Mon Sep 17 00:00:00 2001 From: Anton Melnikov Date: Wed, 21 May 2025 17:37:50 +0200 Subject: [PATCH 2/2] uninstall: style suggestions Co-authored-by: Mike McQuaid --- Library/Homebrew/uninstall.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/uninstall.rb b/Library/Homebrew/uninstall.rb index 206bb6cdbc..c8d0e59ae8 100644 --- a/Library/Homebrew/uninstall.rb +++ b/Library/Homebrew/uninstall.rb @@ -72,12 +72,12 @@ module Homebrew 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) + basename = if File.directory?(path) File.basename(path) - else - File.basename(path, ".*") - end - excluded_names.include?(filename) + else + File.basename(path, ".*") + end + excluded_names.include?(basename) end maybe_paths -= paths if paths.present? if maybe_paths.present?