class Git::Log


@api public
.execute
.between(‘v1.0.7’, ‘HEAD’)
.since(‘10 years ago’)
.object(‘README.md’)
.max_count(:all)
Git::Log.new(git)
@example All commits that match complex criteria
Git::Log.new(git).max_count(:all).execute #=> Enumerable of all commits
@example All commits returned by ‘git log`
Git::Log.new(git).max_commits(50).execute #=> Enumerable of last 50 commits
@example The last n commits
Git::Log.new(git).execute #=> Enumerable of the last 30 commits
git = Git.open(’.‘)
@example The last (default number) of commits
Return the last n commits that match the specified criteria

def [](index)

def [](index)
  deprecate_method(__method__)
  check_log
  @commits[index] rescue nil
end

def all

Returns:
  • (self) -

Other tags:
    Example: Return the last 50 commits reachable by all refs -
def all
  dirty_log
  @all = true
  self
end

def author(regex)

def author(regex)
  dirty_log
  @author = regex
  self
end

def between(sha1, sha2 = nil)

def between(sha1, sha2 = nil)
  dirty_log
  @between = [sha1, sha2]
  self
end

def check_log

def check_log
  if @dirty_flag
    run_log
    @dirty_flag = false
  end
end

def cherry

def cherry
  dirty_log
  @cherry = true
  self
end

def deprecate_method(method_name)

def deprecate_method(method_name)
  Git::Deprecation.warn("Calling Git::Log##{method_name} is deprecated and will be removed in a future version. Call #execute and then ##{method_name} on the result object.")
end

def dirty_log

def dirty_log
  @dirty_flag = true
end

def each(&block)

def each(&block)
  deprecate_method(__method__)
  check_log
  @commits.each(&block)
end

def execute

Returns:
  • (Git::Log::Result) - an object containing the log results
def execute
  run_log
  Result.new(@commits)
end

def first

def first
  deprecate_method(__method__)
  check_log
  @commits.first rescue nil
end

def grep(regex)

def grep(regex)
  dirty_log
  @grep = regex
  self
end

def initialize(base, max_count = 30)

Parameters:
  • max_count (Integer, Symbol, nil) -- the number of commits to return, or
  • base (Git::Base) -- the git repository object
def initialize(base, max_count = 30)
  dirty_log
  @base = base
  max_count(max_count)
end

def last

def last
  deprecate_method(__method__)
  check_log
  @commits.last rescue nil
end

def max_count(num_or_all)

Returns:
  • (self) -

Parameters:
  • num_or_all (Integer, Symbol, nil) -- the number of commits to return, or

Other tags:
    Example: All commits returned by `git log` -
def max_count(num_or_all)
  dirty_log
  @max_count = (num_or_all == :all) ? nil : num_or_all
  self
end

def merges

def merges
  dirty_log
  @merges = true
  self
end

def object(objectish)

def object(objectish)
  dirty_log
  @object = objectish
  self
end

def path(path)

def path(path)
  dirty_log
  @path = path
  self
end

def run_log

actually run the 'git log' command
def run_log
  log = @base.lib.full_log_commits(
    count: @max_count, all: @all, object: @object, path_limiter: @path, since: @since,
    author: @author, grep: @grep, skip: @skip, until: @until, between: @between,
    cherry: @cherry, merges: @merges
  )
  @commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
end

def since(date)

def since(date)
  dirty_log
  @since = date
  self
end

def size

def size
  deprecate_method(__method__)
  check_log
  @commits.size rescue nil
end

def skip(num)

def skip(num)
  dirty_log
  @skip = num
  self
end

def to_s

def to_s
  deprecate_method(__method__)
  check_log
  @commits.map { |c| c.to_s }.join("\n")
end

def until(date)

def until(date)
  dirty_log
  @until = date
  self
end