Files

Grit::GitRuby::Commit

Attributes

author[RW]
committer[RW]
headers[RW]
message[RW]
parent[RW]
tree[RW]

Public Class Methods

from_raw(rawobject, repository=nil) click to toggle source
# File lib/grit/git-ruby/object.rb, line 220
def self.from_raw(rawobject, repository=nil)
  parent = []
  tree = author = committer = nil

  headers, message = rawobject.content.split(/\n\n/, 2)
  all_headers = headers.split(/\n/).map { |header| header.split(/ /, 2) }
  all_headers.each do |key, value|
    case key
    when "tree"
      tree = value
    when "parent"
      parent.push(value)
    when "author"
      author = UserInfo.new(value)
    when "committer"
      committer = UserInfo.new(value)
    else
      warn "unknown header '%s' in commit %s" %              [key, rawobject.sha1.unpack("H*")[0]]
    end
  end
  if not tree && author && committer
    raise RuntimeError, "incomplete raw commit object"
  end
  new(tree, parent, author, committer, message, headers, repository)
end
new(tree, parent, author, committer, message, headers, repository=nil) click to toggle source
# File lib/grit/git-ruby/object.rb, line 247
def initialize(tree, parent, author, committer, message, headers, repository=nil)
  @tree = tree
  @author = author
  @parent = parent
  @committer = committer
  @message = message
  @headers = headers
  @repository = repository
end

Public Instance Methods

raw_content() click to toggle source
# File lib/grit/git-ruby/object.rb, line 261
def raw_content
  "tree %s\n%sauthor %s\ncommitter %s\n\n" % [
    @tree,
    @parent.collect { |i| "parent %s\n" % i }.join,
    @author, @committer] + @message
end
raw_log(sha) click to toggle source
# File lib/grit/git-ruby/object.rb, line 268
def raw_log(sha)
  output = "commit #{sha}\n"
  output += @headers + "\n\n"
  output += @message.split("\n").map { |l| '    ' + l }.join("\n") + "\n\n"
end
type() click to toggle source
# File lib/grit/git-ruby/object.rb, line 257
def type
  :commit
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.