Class Grit::GitRuby::Commit
In: lib/grit/git-ruby/git_object.rb
lib/grit/git-ruby/object.rb
Parent: GitObject

Methods

from_raw   from_raw   new   new   raw_content   raw_content   raw_log   raw_log   type   type  

Attributes

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

Public Class methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 236
236:     def self.from_raw(rawobject, repository=nil)
237:       parent = []
238:       tree = author = committer = nil
239: 
240:       headers, message = rawobject.content.split(/\n\n/, 2)
241:       all_headers = headers.split(/\n/).map { |header| header.split(/ /, 2) }
242:       all_headers.each do |key, value|
243:         case key
244:         when "tree"
245:           tree = value
246:         when "parent"
247:           parent.push(value)
248:         when "author"
249:           author = UserInfo.new(value)
250:         when "committer"
251:           committer = UserInfo.new(value)
252:         else
253:           warn "unknown header '%s' in commit %s" % \
254:             [key, rawobject.sha1.unpack("H*")[0]]
255:         end
256:       end
257:       if not tree && author && committer
258:         raise RuntimeError, "incomplete raw commit object"
259:       end
260:       new(tree, parent, author, committer, message, headers, repository)
261:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 220
220:     def self.from_raw(rawobject, repository=nil)
221:       parent = []
222:       tree = author = committer = nil
223: 
224:       headers, message = rawobject.content.split(/\n\n/, 2)
225:       all_headers = headers.split(/\n/).map { |header| header.split(/ /, 2) }
226:       all_headers.each do |key, value|
227:         case key
228:         when "tree"
229:           tree = value
230:         when "parent"
231:           parent.push(value)
232:         when "author"
233:           author = UserInfo.new(value)
234:         when "committer"
235:           committer = UserInfo.new(value)
236:         else
237:           warn "unknown header '%s' in commit %s" % \
238:             [key, rawobject.sha1.unpack("H*")[0]]
239:         end
240:       end
241:       if not tree && author && committer
242:         raise RuntimeError, "incomplete raw commit object"
243:       end
244:       new(tree, parent, author, committer, message, headers, repository)
245:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 247
247:     def initialize(tree, parent, author, committer, message, headers, repository=nil)
248:       @tree = tree
249:       @author = author
250:       @parent = parent
251:       @committer = committer
252:       @message = message
253:       @headers = headers
254:       @repository = repository
255:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 263
263:     def initialize(tree, parent, author, committer, message, headers, repository=nil)
264:       @tree = tree
265:       @author = author
266:       @parent = parent
267:       @committer = committer
268:       @message = message
269:       @headers = headers
270:       @repository = repository
271:     end

Public Instance methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 277
277:     def raw_content
278:       "tree %s\n%sauthor %s\ncommitter %s\n\n" % [
279:         @tree,
280:         @parent.collect { |i| "parent %s\n" % i }.join,
281:         @author, @committer] + @message
282:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 261
261:     def raw_content
262:       "tree %s\n%sauthor %s\ncommitter %s\n\n" % [
263:         @tree,
264:         @parent.collect { |i| "parent %s\n" % i }.join,
265:         @author, @committer] + @message
266:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 284
284:     def raw_log(sha)
285:       output = "commit #{sha}\n"
286:       output += @headers + "\n\n"
287:       output += @message.split("\n").map { |l| '    ' + l }.join("\n") + "\n\n"
288:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 268
268:     def raw_log(sha)
269:       output = "commit #{sha}\n"
270:       output += @headers + "\n\n"
271:       output += @message.split("\n").map { |l| '    ' + l }.join("\n") + "\n\n"
272:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 257
257:     def type
258:       :commit
259:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 273
273:     def type
274:       :commit
275:     end

[Validate]