aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/log.rb
blob: e2dd08d7c41b10af022692597d29a8a6fe28099d (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
29
30
31
32
#:  * `log` [`git-log-options`] <formula> ...:
#:    Show the git log for the given formulae. Options that `git-log`(1)
#:    recognizes can be passed before the formula list.

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