Merge pull request #2377 from zmwangx/warn-on-slow-missing-formula-search
missing_formula: warn when git-log takes very long
This commit is contained in:
commit
53bcec7679
@ -55,11 +55,10 @@ module Homebrew
|
|||||||
info_formula Formulary.find_with_priority(f)
|
info_formula Formulary.find_with_priority(f)
|
||||||
end
|
end
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
|
ofail e.message
|
||||||
# No formula with this name, try a missing formula lookup
|
# No formula with this name, try a missing formula lookup
|
||||||
if (reason = Homebrew::MissingFormula.reason(f))
|
if (reason = Homebrew::MissingFormula.reason(f))
|
||||||
ofail "#{e.message}\n#{reason}"
|
$stderr.puts reason
|
||||||
else
|
|
||||||
ofail e.message
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,44 +206,47 @@ module Homebrew
|
|||||||
# formula was found, but there's a problem with its implementation).
|
# formula was found, but there's a problem with its implementation).
|
||||||
ofail e.message
|
ofail e.message
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
if (reason = Homebrew::MissingFormula.reason(e.name))
|
if e.name == "updog"
|
||||||
ofail "#{e.message}\n#{reason}"
|
|
||||||
elsif e.name == "updog"
|
|
||||||
ofail "What's 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
|
else
|
||||||
ofail e.message
|
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
|
||||||
|
|
||||||
query = query_regexp(e.name)
|
ohai "Searching taps..."
|
||||||
|
taps_search_results = search_taps(query)
|
||||||
ohai "Searching for similarly named formulae..."
|
case taps_search_results.length
|
||||||
formulae_search_results = search_formulae(query)
|
when 0
|
||||||
case formulae_search_results.length
|
ofail "No formulae found in taps."
|
||||||
when 0
|
when 1
|
||||||
ofail "No similarly named formulae found."
|
puts "This formula was found in a tap:"
|
||||||
when 1
|
puts taps_search_results
|
||||||
puts "This similarly named formula was found:"
|
puts "To install it, run:\n brew install #{taps_search_results.first}"
|
||||||
puts formulae_search_results
|
else
|
||||||
puts "To install it, run:\n brew install #{formulae_search_results.first}"
|
puts "These formulae were found in taps:"
|
||||||
else
|
puts Formatter.columns(taps_search_results)
|
||||||
puts "These similarly named formulae were found:"
|
puts "To install one of them, run (for example):\n brew install #{taps_search_results.first}"
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,7 +67,7 @@ module Homebrew
|
|||||||
if $stdout.tty?
|
if $stdout.tty?
|
||||||
count = local_results.length + tap_results.length
|
count = local_results.length + tap_results.length
|
||||||
|
|
||||||
if reason = Homebrew::MissingFormula.reason(query)
|
if reason = Homebrew::MissingFormula.reason(query, silent: true)
|
||||||
if count > 0
|
if count > 0
|
||||||
puts
|
puts
|
||||||
puts "If you meant #{query.inspect} specifically:"
|
puts "If you meant #{query.inspect} specifically:"
|
||||||
|
@ -5,8 +5,9 @@ require "utils"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module MissingFormula
|
module MissingFormula
|
||||||
class << self
|
class << self
|
||||||
def reason(name)
|
def reason(name, silent: false)
|
||||||
blacklisted_reason(name) || tap_migration_reason(name) || deleted_reason(name)
|
blacklisted_reason(name) || tap_migration_reason(name) ||
|
||||||
|
deleted_reason(name, silent: silent)
|
||||||
end
|
end
|
||||||
|
|
||||||
def blacklisted_reason(name)
|
def blacklisted_reason(name)
|
||||||
@ -117,7 +118,7 @@ module Homebrew
|
|||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
def deleted_reason(name)
|
def deleted_reason(name, silent: false)
|
||||||
path = Formulary.path name
|
path = Formulary.path name
|
||||||
return if File.exist? path
|
return if File.exist? path
|
||||||
tap = Tap.from_path(path)
|
tap = Tap.from_path(path)
|
||||||
@ -125,13 +126,17 @@ module Homebrew
|
|||||||
relative_path = path.relative_path_from tap.path
|
relative_path = path.relative_path_from tap.path
|
||||||
|
|
||||||
tap.path.cd do
|
tap.path.cd do
|
||||||
|
ohai "Searching for a previously deleted formula..." unless silent
|
||||||
|
|
||||||
# We know this may return incomplete results for shallow clones but
|
# We know this may return incomplete results for shallow clones but
|
||||||
# we don't want to nag everyone with a shallow clone to unshallow it.
|
# we don't want to nag everyone with a shallow clone to unshallow it.
|
||||||
log_command = "git log --name-only --max-count=1 --format=%H\\\\n%h\\\\n%B -- #{relative_path}"
|
log_command = "git log --name-only --max-count=1 --format=%H\\\\n%h\\\\n%B -- #{relative_path}"
|
||||||
hash, short_hash, *commit_message, relative_path =
|
hash, short_hash, *commit_message, relative_path =
|
||||||
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)
|
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)
|
||||||
|
|
||||||
if hash.to_s.empty? || short_hash.to_s.empty? ||
|
if hash.to_s.empty? || short_hash.to_s.empty? ||
|
||||||
relative_path.to_s.empty?
|
relative_path.to_s.empty?
|
||||||
|
ofail "No previously deleted formula found." unless silent
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -268,7 +268,6 @@ module GitHub
|
|||||||
|
|
||||||
def print_pull_requests_matching(query)
|
def print_pull_requests_matching(query)
|
||||||
return [] if ENV["HOMEBREW_NO_GITHUB_API"]
|
return [] if ENV["HOMEBREW_NO_GITHUB_API"]
|
||||||
ohai "Searching pull requests..."
|
|
||||||
|
|
||||||
open_or_closed_prs = issues_matching(query, type: "pr")
|
open_or_closed_prs = issues_matching(query, type: "pr")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user