diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 4e29221ac4..b78aacf1b1 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -425,10 +425,33 @@ class Report def dump_formula_report(key, title) formula = select_formula(key) - formula.map! { |oldname, newname| "#{oldname} -> #{newname}" } if key == :R unless formula.empty? + # Determine list item indices of installed formulae. + formula_installed_index = formula.each_index.select do |index| + name, newname = formula[index] + installed?(name) || (newname && installed?(newname)) + end + + # Format list items of renamed formulae. + if key == :R + formula.map! { |oldname, newname| "#{oldname} -> #{newname}" } + end + + # Append suffix '(installed)' to list items of installed formulae. + formula_installed_index.each do |index| + formula[index] += " (installed)" + end + + # Fetch list items of installed formulae for highlighting. + formula_installed = formula.values_at(*formula_installed_index) + + # Dump formula list. ohai title - puts_columns formula + puts_columns(formula, formula_installed) end end + + def installed?(formula) + (HOMEBREW_CELLAR/formula.split("/").last).directory? + end end