missing_formula: print immediately when searching git log.
This commit is contained in:
parent
c458ffbd24
commit
4c2fe5d91e
@ -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,25 +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
|
||||||
begin
|
ohai "Searching for a previously deleted formula..." unless silent
|
||||||
timer_pid = fork do
|
|
||||||
# Let the user know what's going on when the search goes on for
|
|
||||||
# more than two seconds.
|
|
||||||
sleep 2
|
|
||||||
opoo "Searching through git history. This may take a while..."
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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)
|
||||||
ensure
|
|
||||||
Process.kill "TERM", timer_pid
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user