class ReaPack::Index::Git::Commit

Public Class Methods

new(commit, repo) click to toggle source
# File lib/reapack/index/git.rb, line 135
def initialize(commit, repo)
  @commit, @repo = commit, repo
  @parent = commit.parents.first
end

Public Instance Methods

==(o) click to toggle source
# File lib/reapack/index/git.rb, line 177
def ==(o)
  o && id == o.id
end
Also aliased as: eql?
each_diff(&block) click to toggle source
# File lib/reapack/index/git.rb, line 140
def each_diff(&block)
  return @diffs.each &block if @diffs

  if @parent
    diff = @parent.diff id
  else
    diff = @commit.diff
  end

  @diffs = diff.each_delta.map {|delta| Git::Diff.new(delta, @repo) }
  @diffs.each &block
end
eql?(o)
Alias for: ==
filelist() click to toggle source
# File lib/reapack/index/git.rb, line 173
def filelist
  lsfiles @commit.tree
end
hash() click to toggle source
# File lib/reapack/index/git.rb, line 183
def hash
  id.hash
end
id() click to toggle source
# File lib/reapack/index/git.rb, line 153
def id
  @commit.oid
end
inspect() click to toggle source
# File lib/reapack/index/git.rb, line 187
def inspect
  "#<#{self.class} #{id} #{summary}>"
end
message() click to toggle source
# File lib/reapack/index/git.rb, line 161
def message
  @commit.message
end
short_id() click to toggle source
# File lib/reapack/index/git.rb, line 157
def short_id
  id[0...7]
end
summary() click to toggle source
# File lib/reapack/index/git.rb, line 165
def summary
  @commit.summary
end
time() click to toggle source
# File lib/reapack/index/git.rb, line 169
def time
  @commit.time
end

Private Instance Methods

lsfiles(tree, base = String.new) click to toggle source
# File lib/reapack/index/git.rb, line 192
def lsfiles(tree, base = String.new)
  files = []

  tree.each {|obj|
    fullname = base.empty? ? obj[:name] : File.join(base, obj[:name])
    case obj[:type]
    when :blob
      files << fullname
    when :tree
      files.concat lsfiles(@repo.lookup(obj[:oid]), fullname)
    end
  }

  files
end