class Gollum::Git::Commit
Attributes
commit[R]
tracked_pathname[R]
Public Class Methods
new(commit, tracked_pathname = nil)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 109 def initialize(commit, tracked_pathname = nil) @commit = commit @tracked_pathname = tracked_pathname end
Public Instance Methods
id()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 114 def id @commit.oid end
message()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 130 def message @commit.message end
note(ref='refs/notes/commits')
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 146 def note(ref='refs/notes/commits') result = @commit.notes(ref) result ? result[:message] : nil end
note=(msg, actor = nil, ref='refs/notes/commits')
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 151 def note=(msg, actor = nil, ref='refs/notes/commits') actor = Gollum::Git::Actor.default_actor if actor.nil? @commit.create_note( author: actor.to_h, committer: actor.to_h, message: msg, ref: ref, force: true ) end
parent()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 142 def parent @commit.parents.empty? ? nil : Gollum::Git::Commit.new(@commit.parents.first) end
stats()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 138 def stats @stats ||= build_stats end
tree()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 134 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 164 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.find_similar! diff = diff.each_patch do |patch| new_additions = patch.additions new_deletions = patch.deletions additions += new_additions deletions += new_deletions total += patch.changes files << { new_file: patch.delta.new_file[:path].force_encoding("UTF-8"), old_file: patch.delta.renamed? ? patch.delta.old_file[:path].force_encoding("UTF-8") : nil, new_deletions: new_deletions, new_additions: new_additions, changes: patch.changes } end OpenStruct.new(:additions => additions, :deletions => deletions, :files => files, :id => id, :total => total) end