class Gollum::Git::Commit

Attributes

commit[R]

Public Class Methods

new(commit) click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 95
def initialize(commit)
  @commit = commit
end

Public Instance Methods

author() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 107
def author
  @author ||= Gollum::Git::Actor.new(@commit.author[:name], @commit.author[:email])
end
authored_date() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 111
def authored_date
  @commit.author[:time]
end
id() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 99
def id
  @commit.oid
end
Also aliased as: sha, to_s
message() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 115
def message
  @commit.message
end
sha()
Alias for: id
stats() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 123
def stats
  @stats ||= build_stats
end
to_s()
Alias for: id
tree() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 119
def tree
  Gollum::Git::Tree.new(@commit.tree)
end

Private Instance Methods

build_stats() click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 129
def build_stats
  additions = 0
  deletions = 0
  total = 0
  files = []
  parent = @commit.parents.first
  diff = Rugged::Tree.diff(@commit.tree.repo, parent ? parent.tree : nil, @commit.tree)
  diff = diff.each_patch do |patch|
    new_additions = patch.stat[1]
    new_deletions = patch.stat[0]
    additions += new_additions
    deletions += new_deletions
    total += patch.changes
    files << [patch.delta.new_file[:path].force_encoding("UTF-8"), new_deletions, new_additions, patch.changes] # Rugged seems to generate the stat diffs in the other direciton than grit does by default, so switch the order of additions and deletions.
  end
  OpenStruct.new(:additions => additions, :deletions => deletions, :files => files, :id => id, :total => total)
end