Skip to content

Commit

Permalink
autoremove: skip formulae where installed_on_request is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylan12 committed Jun 29, 2024
1 parent a40f327 commit e28d455
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit e28d455

Please sign in to comment.