diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 3629630231..854ca577be 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -84,7 +84,7 @@ module CleanupRefinement resource_name = basename.to_s[/\A.*?\-\-(.*?)\-\-?(?:#{Regexp.escape(version)})/, 1] if resource_name == "patch" - patch_hashes = formula.stable&.patches&.map(&:resource)&.map(&:version) + patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version) return true unless patch_hashes&.include?(Checksum.new(:sha256, version.to_s)) elsif resource_name && resource_version = formula.stable&.resources&.dig(resource_name)&.version return true if resource_version != version