Fix brew list when combining --pinned and --versions
Fixes Homebrew/homebrew#32067 Closes Homebrew/homebrew#32099. Closes Homebrew/homebrew#32134. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
b544f3e5f1
commit
8d23a43f12
@ -10,10 +10,8 @@ module Homebrew
|
|||||||
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
||||||
return unless HOMEBREW_CELLAR.exist?
|
return unless HOMEBREW_CELLAR.exist?
|
||||||
|
|
||||||
if ARGV.include? '--pinned'
|
if ARGV.include? '--pinned' or ARGV.include? '--versions'
|
||||||
list_pinned
|
filtered_list
|
||||||
elsif ARGV.include? '--versions'
|
|
||||||
list_versions
|
|
||||||
elsif ARGV.named.empty?
|
elsif ARGV.named.empty?
|
||||||
ENV['CLICOLOR'] = nil
|
ENV['CLICOLOR'] = nil
|
||||||
exec 'ls', *ARGV.options_only << HOMEBREW_CELLAR
|
exec 'ls', *ARGV.options_only << HOMEBREW_CELLAR
|
||||||
@ -57,29 +55,30 @@ module Homebrew
|
|||||||
exec 'find', *args
|
exec 'find', *args
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_versions
|
def filtered_list
|
||||||
if ARGV.named.empty?
|
names = if ARGV.named.empty?
|
||||||
HOMEBREW_CELLAR.subdirs
|
HOMEBREW_CELLAR.subdirs
|
||||||
else
|
else
|
||||||
ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
|
ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
|
||||||
end.each do |d|
|
end
|
||||||
|
if ARGV.include? '--pinned'
|
||||||
|
pinned_versions = {}
|
||||||
|
names.each do |d|
|
||||||
|
keg_pin = (HOMEBREW_LIBRARY/"PinnedKegs"/d.basename.to_s)
|
||||||
|
if keg_pin.exist? or keg_pin.symlink?
|
||||||
|
pinned_versions[d] = keg_pin.readlink.basename.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pinned_versions.each do |d, version|
|
||||||
|
puts "#{d.basename}".concat(ARGV.include?('--versions') ? " #{version}" : '')
|
||||||
|
end
|
||||||
|
else # --versions without --pinned
|
||||||
|
names.each do |d|
|
||||||
versions = d.subdirs.map { |pn| pn.basename.to_s }
|
versions = d.subdirs.map { |pn| pn.basename.to_s }
|
||||||
next if ARGV.include?('--multiple') && versions.count < 2
|
next if ARGV.include?('--multiple') && versions.count < 2
|
||||||
puts "#{d.basename} #{versions*' '}"
|
puts "#{d.basename} #{versions*' '}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_pinned
|
|
||||||
if ARGV.named.empty?
|
|
||||||
HOMEBREW_CELLAR.subdirs
|
|
||||||
else
|
|
||||||
ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
|
|
||||||
end.select do |d|
|
|
||||||
keg_pin = (HOMEBREW_LIBRARY/"PinnedKegs"/d.basename.to_s)
|
|
||||||
keg_pin.exist? or keg_pin.symlink?
|
|
||||||
end.each do |d|
|
|
||||||
puts d.basename
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user