2016-08-17 01:19:40 +02:00
|
|
|
#: * `log` [<git-log-options>] <formula> ...:
|
2016-04-08 16:28:43 +02:00
|
|
|
#: Show the git log for the given formulae. Options that `git-log`(1)
|
|
|
|
#: recognizes can be passed before the formula list.
|
|
|
|
|
2015-05-08 13:48:36 +08:00
|
|
|
require "formula"
|
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def log
|
|
|
|
if ARGV.named.empty?
|
2017-03-18 16:57:40 +02:00
|
|
|
git_log HOMEBREW_REPOSITORY
|
2010-09-11 20:22:54 +01:00
|
|
|
else
|
2015-05-08 13:48:36 +08:00
|
|
|
path = Formulary.path(ARGV.named.first)
|
2017-03-18 16:57:40 +02:00
|
|
|
tap = Tap.from_path(path)
|
|
|
|
git_log path.dirname, path, tap
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
2015-11-23 15:03:12 +01:00
|
|
|
|
2017-03-18 16:57:40 +02:00
|
|
|
def git_log(cd_dir, path = nil, tap = nil)
|
|
|
|
cd cd_dir
|
|
|
|
repo = Utils.popen_read("git rev-parse --show-toplevel").chomp
|
|
|
|
if tap
|
|
|
|
name = tap.to_s
|
|
|
|
git_cd = "$(brew --repo #{tap})"
|
|
|
|
elsif cd_dir == HOMEBREW_REPOSITORY
|
|
|
|
name = "Homebrew/brew"
|
|
|
|
git_cd = "$(brew --repo)"
|
|
|
|
else
|
|
|
|
name, git_cd = cd_dir
|
|
|
|
end
|
|
|
|
|
|
|
|
if File.exist? "#{repo}/.git/shallow"
|
2015-11-23 15:03:12 +01:00
|
|
|
opoo <<-EOS.undent
|
2017-03-18 16:57:40 +02:00
|
|
|
#{name} is a shallow clone so only partial output will be shown.
|
|
|
|
To get a full clone run:
|
|
|
|
git -C "#{git_cd}" fetch --unshallow
|
2015-11-23 15:03:12 +01:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
args = ARGV.options_only
|
2017-02-12 16:53:22 +00:00
|
|
|
args += ["--follow", "--", path] unless path.nil?
|
2015-11-23 15:03:12 +01:00
|
|
|
exec "git", "log", *args
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|