diff options
| author | Zhiming Wang | 2017-03-22 00:28:01 -0400 |
|---|---|---|
| committer | Mike McQuaid | 2017-03-23 08:39:28 +0000 |
| commit | 5da857ce834323983a52411fd36192d4253090f0 (patch) | |
| tree | ebdf78b72cb2037548b0dc3e13acd2b5569c9d35 /Library/Homebrew | |
| parent | 08a22d013e9ba44aa7c4ed4d08bb2fd6aebf7c05 (diff) | |
| download | brew-5da857ce834323983a52411fd36192d4253090f0.tar.bz2 | |
missing_formula: warn when git-log takes very long
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/missing_formula.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Library/Homebrew/missing_formula.rb b/Library/Homebrew/missing_formula.rb index ba09f7426..8defa86ab 100644 --- a/Library/Homebrew/missing_formula.rb +++ b/Library/Homebrew/missing_formula.rb @@ -125,11 +125,23 @@ module Homebrew relative_path = path.relative_path_from tap.path tap.path.cd do - # 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) + begin + 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 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) + ensure + Process.kill "TERM", timer_pid + end + if hash.to_s.empty? || short_hash.to_s.empty? || relative_path.to_s.empty? return |
