aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/log.rb
blob: 7f9dac40fbb6f0e351508b2127498d8429d63bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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