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 96 def initialize(commit) @commit = commit end
Public Instance Methods
id()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 100 def id @commit.oid end
message()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 116 def message @commit.message end
stats()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 124 def stats @stats ||= build_stats end
tree()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 120 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 130 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