diff options
| author | Mike McQuaid | 2017-03-23 09:51:41 +0000 |
|---|---|---|
| committer | GitHub | 2017-03-23 09:51:41 +0000 |
| commit | 53bcec7679edab4df0b355dfbbef85175da9e75f (patch) | |
| tree | e089cfa9c5bbc575e5c547739d028c6c9ae0ae5f /Library/Homebrew/cmd | |
| parent | 08a22d013e9ba44aa7c4ed4d08bb2fd6aebf7c05 (diff) | |
| parent | 35a4836dc363a69f19fa202deef6ae7a9a2b4440 (diff) | |
| download | brew-53bcec7679edab4df0b355dfbbef85175da9e75f.tar.bz2 | |
Merge pull request #2377 from zmwangx/warn-on-slow-missing-formula-search
missing_formula: warn when git-log takes very long
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/info.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/install.rb | 73 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/search.rb | 2 |
3 files changed, 41 insertions, 39 deletions
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 7e1815556..e7ad6821d 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -55,11 +55,10 @@ module Homebrew info_formula Formulary.find_with_priority(f) end rescue FormulaUnavailableError => e + ofail e.message # No formula with this name, try a missing formula lookup if (reason = Homebrew::MissingFormula.reason(f)) - ofail "#{e.message}\n#{reason}" - else - ofail e.message + $stderr.puts reason end end end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index bd7897171..e54286f09 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -206,44 +206,47 @@ module Homebrew # formula was found, but there's a problem with its implementation). ofail e.message rescue FormulaUnavailableError => e - if (reason = Homebrew::MissingFormula.reason(e.name)) - ofail "#{e.message}\n#{reason}" - elsif e.name == "updog" + if e.name == "updog" ofail "What's updog?" + return + end + + ofail e.message + if (reason = Homebrew::MissingFormula.reason(e.name)) + $stderr.puts reason + return + end + + query = query_regexp(e.name) + + ohai "Searching for similarly named formulae..." + formulae_search_results = search_formulae(query) + case formulae_search_results.length + when 0 + ofail "No similarly named formulae found." + when 1 + puts "This similarly named formula was found:" + puts formulae_search_results + puts "To install it, run:\n brew install #{formulae_search_results.first}" else - ofail e.message - - query = query_regexp(e.name) - - ohai "Searching for similarly named formulae..." - formulae_search_results = search_formulae(query) - case formulae_search_results.length - when 0 - ofail "No similarly named formulae found." - when 1 - puts "This similarly named formula was found:" - puts formulae_search_results - puts "To install it, run:\n brew install #{formulae_search_results.first}" - else - puts "These similarly named formulae were found:" - puts Formatter.columns(formulae_search_results) - puts "To install one of them, run (for example):\n brew install #{formulae_search_results.first}" - end + puts "These similarly named formulae were found:" + puts Formatter.columns(formulae_search_results) + puts "To install one of them, run (for example):\n brew install #{formulae_search_results.first}" + end - ohai "Searching taps..." - taps_search_results = search_taps(query) - case taps_search_results.length - when 0 - ofail "No formulae found in taps." - when 1 - puts "This formula was found in a tap:" - puts taps_search_results - puts "To install it, run:\n brew install #{taps_search_results.first}" - else - puts "These formulae were found in taps:" - puts Formatter.columns(taps_search_results) - puts "To install one of them, run (for example):\n brew install #{taps_search_results.first}" - end + ohai "Searching taps..." + taps_search_results = search_taps(query) + case taps_search_results.length + when 0 + ofail "No formulae found in taps." + when 1 + puts "This formula was found in a tap:" + puts taps_search_results + puts "To install it, run:\n brew install #{taps_search_results.first}" + else + puts "These formulae were found in taps:" + puts Formatter.columns(taps_search_results) + puts "To install one of them, run (for example):\n brew install #{taps_search_results.first}" end end end diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index db5898872..443739f8c 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -67,7 +67,7 @@ module Homebrew if $stdout.tty? count = local_results.length + tap_results.length - if reason = Homebrew::MissingFormula.reason(query) + if reason = Homebrew::MissingFormula.reason(query, silent: true) if count > 0 puts puts "If you meant #{query.inspect} specifically:" |
