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)
|
||||
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
|
||||
|
@ -206,12 +206,16 @@ 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?"
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
ofail e.message
|
||||
if (reason = Homebrew::MissingFormula.reason(e.name))
|
||||
$stderr.puts reason
|
||||
return
|
||||
end
|
||||
|
||||
query = query_regexp(e.name)
|
||||
|
||||
@ -246,7 +250,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_ppc
|
||||
case Hardware::CPU.type
|
||||
|
@ -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:"
|
||||
|
@ -5,8 +5,9 @@ require "utils"
|
||||
module Homebrew
|
||||
module MissingFormula
|
||||
class << self
|
||||
def reason(name)
|
||||
blacklisted_reason(name) || tap_migration_reason(name) || deleted_reason(name)
|
||||
def reason(name, silent: false)
|
||||
blacklisted_reason(name) || tap_migration_reason(name) ||
|
||||
deleted_reason(name, silent: silent)
|
||||
end
|
||||
|
||||
def blacklisted_reason(name)
|
||||
@ -117,7 +118,7 @@ module Homebrew
|
||||
message
|
||||
end
|
||||
|
||||
def deleted_reason(name)
|
||||
def deleted_reason(name, silent: false)
|
||||
path = Formulary.path name
|
||||
return if File.exist? path
|
||||
tap = Tap.from_path(path)
|
||||
@ -125,13 +126,17 @@ module Homebrew
|
||||
relative_path = path.relative_path_from tap.path
|
||||
|
||||
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 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}"
|
||||
hash, short_hash, *commit_message, relative_path =
|
||||
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)
|
||||
|
||||
if hash.to_s.empty? || short_hash.to_s.empty? ||
|
||||
relative_path.to_s.empty?
|
||||
ofail "No previously deleted formula found." unless silent
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -268,7 +268,6 @@ module GitHub
|
||||
|
||||
def print_pull_requests_matching(query)
|
||||
return [] if ENV["HOMEBREW_NO_GITHUB_API"]
|
||||
ohai "Searching pull requests..."
|
||||
|
||||
open_or_closed_prs = issues_matching(query, type: "pr")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user