Class: Grit::GitRuby::Commit
- Inherits:
-
GitObject
- Object
- GitObject
- Grit::GitRuby::Commit
- Defined in:
- lib/grit/git-ruby/git_object.rb
Instance Attribute Summary (collapse)
-
- (Object) author
Returns the value of attribute author.
-
- (Object) committer
Returns the value of attribute committer.
-
- (Object) headers
Returns the value of attribute headers.
-
- (Object) message
Returns the value of attribute message.
-
- (Object) parent
Returns the value of attribute parent.
-
- (Object) tree
Returns the value of attribute tree.
Attributes inherited from GitObject
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Commit) initialize(tree, parent, author, committer, message, headers, repository = nil)
constructor
A new instance of Commit.
- - (Object) raw_content
- - (Object) raw_log(sha)
- - (Object) type
Methods inherited from GitObject
Constructor Details
- (Commit) initialize(tree, parent, author, committer, message, headers, repository = nil)
A new instance of Commit
264 265 266 267 268 269 270 271 272 |
# File 'lib/grit/git-ruby/git_object.rb', line 264 def initialize(tree, parent, , committer, , headers, repository=nil) @tree = tree @author = @parent = parent @committer = committer @message = @headers = headers @repository = repository end |
Instance Attribute Details
- (Object) author
Returns the value of attribute author
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def @author end |
- (Object) committer
Returns the value of attribute committer
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def committer @committer end |
- (Object) headers
Returns the value of attribute headers
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def headers @headers end |
- (Object) message
Returns the value of attribute message
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def @message end |
- (Object) parent
Returns the value of attribute parent
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def parent @parent end |
- (Object) tree
Returns the value of attribute tree
235 236 237 |
# File 'lib/grit/git-ruby/git_object.rb', line 235 def tree @tree end |
Class Method Details
+ (Object) from_raw(rawobject, repository = nil)
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/grit/git-ruby/git_object.rb', line 237 def self.from_raw(rawobject, repository=nil) parent = [] tree = = committer = nil headers, = 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" = 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 && && committer raise RuntimeError, "incomplete raw commit object" end new(tree, parent, , committer, , headers, repository) end |
Instance Method Details
- (Object) raw_content
278 279 280 281 282 283 |
# File 'lib/grit/git-ruby/git_object.rb', line 278 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 |
- (Object) raw_log(sha)
285 286 287 288 289 |
# File 'lib/grit/git-ruby/git_object.rb', line 285 def raw_log(sha) output = "commit #{sha}\n" output += @headers + "\n\n" output += @message.split("\n").map { |l| ' ' + l }.join("\n") + "\n\n" end |
- (Object) type
274 275 276 |
# File 'lib/grit/git-ruby/git_object.rb', line 274 def type :commit end |