update-report: default HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED to on.
This avoids reading formula files that the user hasn't explicitly installed which both speeds up `brew update` and improves the security.
This commit is contained in:
parent
6661f5b14d
commit
10d5266361
@ -331,9 +331,6 @@ class Reporter
|
|||||||
|
|
||||||
if paths.any? { |p| tap.cask_file?(p) }
|
if paths.any? { |p| tap.cask_file?(p) }
|
||||||
case status
|
case status
|
||||||
when "A"
|
|
||||||
# Have a dedicated report array for new casks.
|
|
||||||
@report[:AC] << tap.formula_file_to_name(src)
|
|
||||||
when "D"
|
when "D"
|
||||||
# Have a dedicated report array for deleted casks.
|
# Have a dedicated report array for deleted casks.
|
||||||
@report[:DC] << tap.formula_file_to_name(src)
|
@report[:DC] << tap.formula_file_to_name(src)
|
||||||
@ -413,12 +410,14 @@ class Reporter
|
|||||||
renamed_formulae << [old_full_name, new_full_name]
|
renamed_formulae << [old_full_name, new_full_name]
|
||||||
end
|
end
|
||||||
|
|
||||||
unless renamed_formulae.empty?
|
if renamed_formulae.present?
|
||||||
@report[:A] -= renamed_formulae.map(&:last)
|
@report[:A] -= renamed_formulae.map(&:last)
|
||||||
@report[:D] -= renamed_formulae.map(&:first)
|
@report[:D] -= renamed_formulae.map(&:first)
|
||||||
@report[:R] = renamed_formulae.to_a
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Only needed additions for calculating deletions correctly based on renames.
|
||||||
|
@report.delete(:A)
|
||||||
|
|
||||||
@report
|
@report
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -569,18 +568,18 @@ class ReporterHub
|
|||||||
delegate empty?: :@hash
|
delegate empty?: :@hash
|
||||||
|
|
||||||
def dump(updated_formula_report: true)
|
def dump(updated_formula_report: true)
|
||||||
# Key Legend: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
|
if ENV["HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED"]
|
||||||
|
opoo "HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED can be unset, it is now the default!"
|
||||||
|
end
|
||||||
|
|
||||||
dump_formula_report :A, "New Formulae"
|
# Key Legend: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
|
||||||
if updated_formula_report
|
if updated_formula_report
|
||||||
dump_formula_report :M, "Updated Formulae"
|
dump_formula_report :M, "Updated Formulae"
|
||||||
else
|
else
|
||||||
updated = select_formula(:M).count
|
updated = select_formula(:M).count
|
||||||
ohai "Updated Formulae", "Updated #{updated} #{"formula".pluralize(updated)}." if updated.positive?
|
ohai "Updated Formulae", "Updated #{updated} #{"formula".pluralize(updated)}." if updated.positive?
|
||||||
end
|
end
|
||||||
dump_formula_report :R, "Renamed Formulae"
|
|
||||||
dump_formula_report :D, "Deleted Formulae"
|
dump_formula_report :D, "Deleted Formulae"
|
||||||
dump_formula_report :AC, "New Casks"
|
|
||||||
if updated_formula_report
|
if updated_formula_report
|
||||||
dump_formula_report :MC, "Updated Casks"
|
dump_formula_report :MC, "Updated Casks"
|
||||||
else
|
else
|
||||||
@ -593,33 +592,13 @@ class ReporterHub
|
|||||||
private
|
private
|
||||||
|
|
||||||
def dump_formula_report(key, title)
|
def dump_formula_report(key, title)
|
||||||
# TODO: 3.4.0: odisabled the old functionality and make this default
|
formulae = select_formula(key).sort.map do |name, _new_name|
|
||||||
only_installed = Homebrew::EnvConfig.update_report_only_installed?
|
|
||||||
|
|
||||||
formulae = select_formula(key).sort.map do |name, new_name|
|
|
||||||
# Format list items of renamed formulae
|
|
||||||
case key
|
case key
|
||||||
when :R
|
|
||||||
name = pretty_installed(name) if installed?(name)
|
|
||||||
new_name = pretty_installed(new_name) if installed?(new_name)
|
|
||||||
"#{name} -> #{new_name}" unless only_installed
|
|
||||||
when :A
|
|
||||||
name if !installed?(name) && !only_installed
|
|
||||||
when :AC
|
|
||||||
name.split("/").last if !cask_installed?(name) && !only_installed
|
|
||||||
when :MC, :DC
|
when :MC, :DC
|
||||||
name = name.split("/").last
|
name = name.split("/").last
|
||||||
if cask_installed?(name)
|
pretty_installed(name) if cask_installed?(name)
|
||||||
pretty_installed(name)
|
when :M, :D
|
||||||
elsif !only_installed
|
pretty_installed(name) if installed?(name)
|
||||||
name
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if installed?(name)
|
|
||||||
pretty_installed(name)
|
|
||||||
elsif !only_installed
|
|
||||||
name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
|
|||||||
@ -325,10 +325,6 @@ module Homebrew
|
|||||||
default_text: "macOS: `/private/tmp`, Linux: `/tmp`.",
|
default_text: "macOS: `/private/tmp`, Linux: `/tmp`.",
|
||||||
default: HOMEBREW_DEFAULT_TEMP,
|
default: HOMEBREW_DEFAULT_TEMP,
|
||||||
},
|
},
|
||||||
HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED: {
|
|
||||||
description: "If set, `brew update` only lists updates to installed software.",
|
|
||||||
boolean: true,
|
|
||||||
},
|
|
||||||
HOMEBREW_UPDATE_TO_TAG: {
|
HOMEBREW_UPDATE_TO_TAG: {
|
||||||
description: "If set, always use the latest stable tag (even if developer commands " \
|
description: "If set, always use the latest stable tag (even if developer commands " \
|
||||||
"have been run).",
|
"have been run).",
|
||||||
|
|||||||
@ -2626,8 +2626,6 @@ module Homebrew::EnvConfig
|
|||||||
|
|
||||||
def self.temp(); end
|
def self.temp(); end
|
||||||
|
|
||||||
def self.update_report_only_installed?(); end
|
|
||||||
|
|
||||||
def self.update_to_tag?(); end
|
def self.update_to_tag?(); end
|
||||||
|
|
||||||
def self.verbose?(); end
|
def self.verbose?(); end
|
||||||
|
|||||||
@ -53,7 +53,6 @@ describe "brew update-report" do
|
|||||||
perform_update("update_git_diff_output_without_formulae_changes")
|
perform_update("update_git_diff_output_without_formulae_changes")
|
||||||
|
|
||||||
expect(hub.select_formula(:M)).to be_empty
|
expect(hub.select_formula(:M)).to be_empty
|
||||||
expect(hub.select_formula(:A)).to be_empty
|
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ describe "brew update-report" do
|
|||||||
perform_update("update_git_diff_output_with_formulae_changes")
|
perform_update("update_git_diff_output_with_formulae_changes")
|
||||||
|
|
||||||
expect(hub.select_formula(:M)).to eq(%w[xar yajl])
|
expect(hub.select_formula(:M)).to eq(%w[xar yajl])
|
||||||
expect(hub.select_formula(:A)).to eq(%w[antiword bash-completion ddrescue dict lua])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with removed Formulae" do
|
specify "with removed Formulae" do
|
||||||
@ -74,7 +72,6 @@ describe "brew update-report" do
|
|||||||
perform_update("update_git_diff_output_with_changed_filetype")
|
perform_update("update_git_diff_output_with_changed_filetype")
|
||||||
|
|
||||||
expect(hub.select_formula(:M)).to eq(%w[elixir])
|
expect(hub.select_formula(:M)).to eq(%w[elixir])
|
||||||
expect(hub.select_formula(:A)).to eq(%w[libbson])
|
|
||||||
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
expect(hub.select_formula(:D)).to eq(%w[libgsasl])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -82,9 +79,7 @@ describe "brew update-report" do
|
|||||||
allow(tap).to receive(:formula_renames).and_return("cv" => "progress")
|
allow(tap).to receive(:formula_renames).and_return("cv" => "progress")
|
||||||
perform_update("update_git_diff_output_with_formula_rename")
|
perform_update("update_git_diff_output_with_formula_rename")
|
||||||
|
|
||||||
expect(hub.select_formula(:A)).to be_empty
|
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
expect(hub.select_formula(:R)).to eq([["cv", "progress"]])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when updating a Tap other than the core Tap" do
|
context "when updating a Tap other than the core Tap" do
|
||||||
@ -101,32 +96,25 @@ describe "brew update-report" do
|
|||||||
specify "with restructured Tap" do
|
specify "with restructured Tap" do
|
||||||
perform_update("update_git_diff_output_with_restructured_tap")
|
perform_update("update_git_diff_output_with_restructured_tap")
|
||||||
|
|
||||||
expect(hub.select_formula(:A)).to be_empty
|
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
expect(hub.select_formula(:R)).to be_empty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with renamed Formula and restructured Tap" do
|
specify "with renamed Formula and restructured Tap" do
|
||||||
allow(tap).to receive(:formula_renames).and_return("xchat" => "xchat2")
|
allow(tap).to receive(:formula_renames).and_return("xchat" => "xchat2")
|
||||||
perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
|
perform_update("update_git_diff_output_with_formula_rename_and_restructuring")
|
||||||
|
|
||||||
expect(hub.select_formula(:A)).to be_empty
|
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
expect(hub.select_formula(:R)).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with simulated 'homebrew/php' restructuring" do
|
specify "with simulated 'homebrew/php' restructuring" do
|
||||||
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
|
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
|
||||||
|
|
||||||
expect(hub.select_formula(:A)).to be_empty
|
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
expect(hub.select_formula(:R)).to be_empty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "with Formula changes" do
|
specify "with Formula changes" do
|
||||||
perform_update("update_git_diff_output_with_tap_formulae_changes")
|
perform_update("update_git_diff_output_with_tap_formulae_changes")
|
||||||
|
|
||||||
expect(hub.select_formula(:A)).to eq(%w[foo/bar/lua])
|
|
||||||
expect(hub.select_formula(:M)).to eq(%w[foo/bar/git])
|
expect(hub.select_formula(:M)).to eq(%w[foo/bar/git])
|
||||||
expect(hub.select_formula(:D)).to be_empty
|
expect(hub.select_formula(:D)).to be_empty
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user