From b9f493a7f694cbe92af6d3e823db0961105246c2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 18 May 2020 12:46:23 +0100 Subject: [PATCH] Pass FormulaInstaller#display_options to BuildError. This should improve the output in analytics. --- Library/Homebrew/formula_installer.rb | 17 ++++++++--------- Library/Homebrew/utils/analytics.rb | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index dcf57c4d66..18ed7cb437 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -279,7 +279,7 @@ class FormulaInstaller opoo "#{formula.full_name}: #{old_flag} was deprecated; using #{new_flag} instead!" end - options = display_options(formula) + options = display_options(formula).join(" ") oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header? unless formula.tap&.private? @@ -529,16 +529,15 @@ class FormulaInstaller end def display_options(formula) - options = [] - if formula.head? - options << "--HEAD" + options = if formula.head? + ["--HEAD"] elsif formula.devel? - options << "--devel" + ["--devel"] + else + [] end options += effective_build_options_for(formula).used_options.to_a - return if options.empty? - - options.join(" ") + options end def inherited_options_for(dep) @@ -793,7 +792,7 @@ class FormulaInstaller rescue Exception => e # rubocop:disable Lint/RescueException if e.is_a? BuildError e.formula = formula - e.options = options + e.options = display_options(formula) end ignore_interrupts do diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index f2163355bf..c3a8bc03c9 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -67,8 +67,8 @@ module Utils return if exception.formula.tap.private? action = exception.formula.full_name - if (options = exception.options.to_a.presence) - action = "#{action} #{options.map(&:to_s).join(" ")}".strip + if (options = exception.options.to_a.map(&:to_s).join(" ").presence) + action = "#{action} #{options}".strip end report_event("BuildError", action) end