Skip to content

Commit

Permalink
Merge pull request #10581 from Bo98/update-report-outdated
Browse files Browse the repository at this point in the history
cmd/update-report: report outdated count & suggest `brew upgrade`
  • Loading branch information
Bo98 authored Feb 11, 2021
2 parents 0f4ccd7 + 0e732d3 commit effe4ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Library/Homebrew/cmd/update-report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,28 @@ def update_report
DescriptionCacheStore.new(db)
.update_from_report!(hub)
end

unless args.preinstall?
outdated_formulae = Formula.installed.count(&:outdated?)
outdated_casks = Cask::Caskroom.casks.count(&:outdated?)
msg = ""
if outdated_formulae.positive?
msg += "#{Tty.bold}#{outdated_formulae}#{Tty.reset} outdated #{"formula".pluralize(outdated_formulae)}"
end
if outdated_casks.positive?
msg += " and " if msg.present?
msg += "#{Tty.bold}#{outdated_casks}#{Tty.reset} outdated #{"cask".pluralize(outdated_casks)}"
end
if msg.present?
puts_stdout_or_stderr
puts_stdout_or_stderr <<~EOS
You have #{msg} installed.
You can update them with #{Tty.bold}brew upgrade#{Tty.reset}.
EOS
end
end
end
puts if args.preinstall?
puts_stdout_or_stderr if args.preinstall?
elsif !args.preinstall? && !ENV["HOMEBREW_UPDATE_FAILED"]
puts_stdout_or_stderr "Already up-to-date." unless args.quiet?
end
Expand All @@ -161,6 +181,7 @@ def update_report

return if new_repository_version.blank?

puts_stdout_or_stderr
ohai_stdout_or_stderr "Homebrew was updated to version #{new_repository_version}"
if new_repository_version.split(".").last == "0"
puts_stdout_or_stderr <<~EOS
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def ohai_stdout_or_stderr(message, *sput)
end

def puts_stdout_or_stderr(*message)
message = "\n" if message.empty?
if $stdout.tty?
puts(message)
else
Expand Down

0 comments on commit effe4ac

Please sign in to comment.