Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoremove: skip formulae where installed_on_request is nil #17589

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Library/Homebrew/test/utils/autoremove_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
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
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/utils/autoremove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def bottled_formulae_with_no_formula_dependents(formulae)
# @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?
Expand Down