Skip to content

Commit

Permalink
brew unbottled: allow to skip deprecated and change format
Browse files Browse the repository at this point in the history
- Display if a formula is deprecated (helps focusing on the more important ones first when bottling)
- Allows to skip deprecated formuale for a more curated list
  • Loading branch information
iMichka committed Oct 16, 2023
1 parent c0c8a4d commit 17cfa3d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Library/Homebrew/dev-cmd/unbottled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def unbottled_args
switch "--eval-all",
description: "Evaluate all available formulae and casks, whether installed or not, to check them. " \
"Implied if `HOMEBREW_EVAL_ALL` is set."
switch "--skip-deprecated",
description: "Don't check deprecated formulae"

conflicts "--dependents", "--total"

Expand Down Expand Up @@ -137,6 +139,12 @@ def formulae_all_installs_from_args(args, all)
all_formulae = Formula.all(eval_all: args.eval_all?)
end

if args.skip_deprecated?
formulae = formulae&.select {|formula| !(formula.deprecated?)}
all_formulae = all_formulae&.select {|formula| !(formula.deprecated?)}
formula_installs = formula_installs&.select {|formula| !(formula.deprecated?)}
end

[formulae, all_formulae, formula_installs]
end

Expand Down Expand Up @@ -180,6 +188,7 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args)

formulae.each do |f|
name = f.name.downcase
deprecated = "(deprecated)" if f.deprecated?

if f.disabled?
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: formula disabled" if any_named_args
Expand All @@ -189,11 +198,11 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args)
requirements = f.recursive_requirements
if @bottle_tag.linux?
if requirements.any? { |r| r.is_a?(MacOSRequirement) && !r.version }
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires macOS" if any_named_args
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset} #{deprecated}: requires macOS" if any_named_args
next
end
elsif requirements.any?(LinuxRequirement)
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: requires Linux" if any_named_args
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset} #{deprecated}: requires Linux" if any_named_args
next
else
macos_version = @bottle_tag.to_macos_version
Expand All @@ -214,13 +223,13 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args)
end
end
unless macos_satisfied
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset}: doesn't support this macOS" if any_named_args
puts "#{Tty.bold}#{Tty.red}#{name}#{Tty.reset} #{deprecated}: doesn't support this macOS" if any_named_args
next
end
end

if f.bottle_specification.tag?(@bottle_tag, no_older_versions: true)
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset} #{deprecated}: already bottled" if any_named_args
next
end

Expand All @@ -230,13 +239,13 @@ def output_unbottled(formulae, deps_hash, noun, hash, any_named_args)

if deps.blank?
count = " (#{hash[f.name]} #{noun})" if noun
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}#{count}: ready to bottle"
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}#{count} #{deprecated}: ready to bottle"
next
end

any_found ||= true
count = " (#{hash[f.name]} #{noun})" if noun
puts "#{Tty.bold}#{Tty.yellow}#{name}#{Tty.reset}#{count}: unbottled deps: #{deps.join(" ")}"
puts "#{Tty.bold}#{Tty.yellow}#{name}#{Tty.reset}#{count} #{deprecated}: unbottled deps: #{deps.join(" ")}"
end
return if any_found
return if any_named_args
Expand Down

0 comments on commit 17cfa3d

Please sign in to comment.