<commit_before>require "formula"

module Homebrew
  def log
    if ARGV.named.empty?
      cd HOMEBREW_REPOSITORY
      exec "git", "log", *ARGV.options_only
    else
      path = Formulary.path(ARGV.named.first)
      cd path.dirname # supports taps
      exec "git", "log", *ARGV.options_only + ["--", path]
    end
  end
end<commit_msg>brew-log: warn if shallow clone<commit_after>require "formula"

module Homebrew
  def log
    if ARGV.named.empty?
      cd HOMEBREW_REPOSITORY
      git_log
    else
      path = Formulary.path(ARGV.named.first)
      cd path.dirname # supports taps
      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
{'fraction_non_alphanumeric': 0.10404624277456648, 'fraction_numerical': 0.0, 'mean_word_length': 2.522033898305085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7028738', 'n_tokens_mistral': 362, 'n_tokens_neox': 347, 'n_words': 100}