brew-log: warn if shallow clone

Closes Homebrew/homebrew#46283.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-11-23 15:03:12 +01:00
parent cd267e0bce
commit e8c8b876af

View File

@ -4,11 +4,25 @@ module Homebrew
def log
if ARGV.named.empty?
cd HOMEBREW_REPOSITORY
exec "git", "log", *ARGV.options_only
git_log
else
path = Formulary.path(ARGV.named.first)
cd path.dirname # supports taps
exec "git", "log", *ARGV.options_only + ["--", path]
git_log path
end
end
private
def git_log(path=nil)
if File.exist? "#{`git rev-parse --show-toplevel`.chomp}/.git/shallow"
opoo <<-EOS.undent
The git repository is a shallow clone therefore the filtering may be incorrect.
Use `git fetch --unshallow` to get the full repository.
EOS
end
args = ARGV.options_only
args += ["--", path] unless path.nil?
exec "git", "log", *args
end
end