Class: Grit::GitRuby::Commit
- Defined in:
- lib/grit/git-ruby/object.rb,
lib/grit/git-ruby/git_object.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#committer ⇒ Object
Returns the value of attribute committer.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#message ⇒ Object
Returns the value of attribute message.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#tree ⇒ Object
Returns the value of attribute tree.
Attributes inherited from GitObject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tree, parent, author, committer, message, headers, repository = nil) ⇒ Commit
constructor
A new instance of Commit.
- #raw_content ⇒ Object
- #raw_log(sha) ⇒ Object
- #type ⇒ Object
Methods inherited from GitObject
Constructor Details
#initialize(tree, parent, author, committer, message, headers, repository = nil) ⇒ Commit
Returns a new instance of Commit.
247 248 249 250 251 252 253 254 255 |
# File 'lib/grit/git-ruby/object.rb', line 247 def initialize(tree, parent, , committer, , headers, repository=nil) @tree = tree @author = @parent = parent @committer = committer @message = @headers = headers @repository = repository end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def @author end |
#committer ⇒ Object
Returns the value of attribute committer.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def committer @committer end |
#headers ⇒ Object
Returns the value of attribute headers.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def headers @headers end |
#message ⇒ Object
Returns the value of attribute message.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def @message end |
#parent ⇒ Object
Returns the value of attribute parent.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def parent @parent end |
#tree ⇒ Object
Returns the value of attribute tree.
218 219 220 |
# File 'lib/grit/git-ruby/object.rb', line 218 def tree @tree end |
Class Method Details
.from_raw(rawobject, repository = nil) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/grit/git-ruby/object.rb', line 220 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
#raw_content ⇒ Object
261 262 263 264 265 266 |
# 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) ⇒ Object
268 269 270 271 272 |
# 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 ⇒ Object
257 258 259 |
# File 'lib/grit/git-ruby/object.rb', line 257 def type :commit end |