Merge pull request #17589 from Homebrew/autoremove-skip-nil

This commit is contained in:
Rylan Polster 2024-06-29 10:39:54 -04:00 committed by GitHub
commit fda555d7e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -107,6 +107,13 @@ RSpec.describe Utils::Autoremove do
expect(described_class.send(:unused_formulae_with_no_formula_dependents, formulae))
.to match_array(formulae)
end
specify "installed on request is null" do
allow(tab_from_keg).to receive(:installed_on_request).and_return(nil)
expect(described_class.send(:unused_formulae_with_no_formula_dependents, formulae))
.to eq([])
end
end
shared_context "with formulae and casks for dependency testing" do

View File

@ -61,8 +61,8 @@ module Utils
# @private
sig { params(formulae: T::Array[Formula]).returns(T::Array[Formula]) }
def unused_formulae_with_no_formula_dependents(formulae)
unused_formulae = bottled_formulae_with_no_formula_dependents(formulae).reject do |f|
f.any_installed_keg&.tab&.installed_on_request
unused_formulae = bottled_formulae_with_no_formula_dependents(formulae).select do |f|
f.any_installed_keg&.tab&.installed_on_request == false
end
unless unused_formulae.empty?