make suggestions
This commit is contained in:
parent
b5d5be3474
commit
afd7bb8889
@ -6,8 +6,6 @@ require "cli/parser"
|
|||||||
require "uninstall"
|
require "uninstall"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend Uninstall
|
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def autoremove_args
|
def autoremove_args
|
||||||
@ -24,7 +22,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_removable_formulae(formulae)
|
def get_removable_formulae(formulae)
|
||||||
removable_formulae = Formula.installed_non_deps(formulae).reject do |f|
|
removable_formulae = Formula.installed_formulae_with_no_dependents(formulae).reject do |f|
|
||||||
Tab.for_keg(f.any_installed_keg).installed_on_request
|
Tab.for_keg(f.any_installed_keg).installed_on_request
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,12 +40,14 @@ module Homebrew
|
|||||||
|
|
||||||
formulae_names = removable_formulae.map(&:full_name).sort
|
formulae_names = removable_formulae.map(&:full_name).sort
|
||||||
|
|
||||||
oh1 "Formulae that could be removed"
|
intent = args.dry_run? ? "could" : "will"
|
||||||
|
oh1 "Formulae that #{intent} be removed"
|
||||||
puts formulae_names
|
puts formulae_names
|
||||||
|
|
||||||
return if args.dry_run?
|
return if args.dry_run?
|
||||||
|
|
||||||
|
puts
|
||||||
kegs_by_rack = removable_formulae.map(&:any_installed_keg).group_by(&:rack)
|
kegs_by_rack = removable_formulae.map(&:any_installed_keg).group_by(&:rack)
|
||||||
uninstall_kegs(kegs_by_rack)
|
Uninstall.uninstall_kegs(kegs_by_rack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,7 +22,6 @@ module Homebrew
|
|||||||
def leaves
|
def leaves
|
||||||
leaves_args.parse
|
leaves_args.parse
|
||||||
|
|
||||||
leaves = Formula.installed_non_deps.map(&:full_name).sort
|
Formula.installed_formulae_with_no_dependents.map(&:full_name).sort.each(&method(:puts))
|
||||||
leaves.each(&method(:puts))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -11,8 +11,6 @@ require "cask/cask_loader"
|
|||||||
require "uninstall"
|
require "uninstall"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend Uninstall
|
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def uninstall_args
|
def uninstall_args
|
||||||
@ -57,10 +55,10 @@ module Homebrew
|
|||||||
kegs_by_rack = all_kegs.group_by(&:rack)
|
kegs_by_rack = all_kegs.group_by(&:rack)
|
||||||
end
|
end
|
||||||
|
|
||||||
uninstall_kegs(kegs_by_rack,
|
Uninstall.uninstall_kegs(kegs_by_rack,
|
||||||
force: args.force?,
|
force: args.force?,
|
||||||
ignore_dependencies: args.ignore_dependencies?,
|
ignore_dependencies: args.ignore_dependencies?,
|
||||||
named_args: args.named)
|
named_args: args.named)
|
||||||
|
|
||||||
return if casks.blank?
|
return if casks.blank?
|
||||||
|
|
||||||
|
|||||||
@ -1515,16 +1515,12 @@ class Formula
|
|||||||
end.uniq(&:name)
|
end.uniq(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# An array of installed {Formula} that are dependencies of other installed {Formula}
|
# An array of all installed {Formula} without dependents
|
||||||
# @private
|
# @private
|
||||||
def self.installed_deps(formulae = installed)
|
def self.installed_formulae_with_no_dependents(formulae = installed)
|
||||||
formulae.flat_map(&:runtime_formula_dependencies).uniq(&:name)
|
return [] if formulae.blank?
|
||||||
end
|
|
||||||
|
|
||||||
# An array of all installed {Formula} that are not dependencies of other installed {Formula}
|
formulae - formulae.flat_map(&:runtime_formula_dependencies)
|
||||||
# @private
|
|
||||||
def self.installed_non_deps(formulae = installed)
|
|
||||||
formulae - installed_deps(formulae)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.installed_with_alias_path(alias_path)
|
def self.installed_with_alias_path(alias_path)
|
||||||
|
|||||||
@ -440,7 +440,7 @@ describe Formula do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::installed_deps" do
|
describe "::installed_formulae_with_no_dependents" do
|
||||||
let(:formula_is_dep) do
|
let(:formula_is_dep) do
|
||||||
formula "foo" do
|
formula "foo" do
|
||||||
url "foo-1.1"
|
url "foo-1.1"
|
||||||
@ -467,49 +467,12 @@ describe Formula do
|
|||||||
specify "without formulae parameter" do
|
specify "without formulae parameter" do
|
||||||
allow(described_class).to receive(:installed).and_return(formulae)
|
allow(described_class).to receive(:installed).and_return(formulae)
|
||||||
|
|
||||||
expect(described_class.installed_deps)
|
expect(described_class.installed_formulae_with_no_dependents)
|
||||||
.to eq([formula_is_dep])
|
|
||||||
end
|
|
||||||
|
|
||||||
specify "with formulae parameter" do
|
|
||||||
expect(described_class.installed_deps(formulae))
|
|
||||||
.to eq([formula_is_dep])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "::installed_non_deps" do
|
|
||||||
let(:formula_is_dep) do
|
|
||||||
formula "foo" do
|
|
||||||
url "foo-1.1"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:formula_with_deps) do
|
|
||||||
formula "bar" do
|
|
||||||
url "bar-1.0"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:formulae) do
|
|
||||||
[
|
|
||||||
formula_with_deps,
|
|
||||||
formula_is_dep,
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(formula_with_deps).to receive(:runtime_formula_dependencies).and_return([formula_is_dep])
|
|
||||||
end
|
|
||||||
|
|
||||||
specify "without formulae parameter" do
|
|
||||||
allow(described_class).to receive(:installed).and_return(formulae)
|
|
||||||
|
|
||||||
expect(described_class.installed_non_deps)
|
|
||||||
.to eq([formula_with_deps])
|
.to eq([formula_with_deps])
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with formulae parameter" do
|
specify "with formulae parameter" do
|
||||||
expect(described_class.installed_non_deps(formulae))
|
expect(described_class.installed_formulae_with_no_dependents(formulae))
|
||||||
.to eq([formula_with_deps])
|
.to eq([formula_with_deps])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user