Class: Gitrb::Commit

Inherits:
GitObject show all
Defined in:
lib/gitrb/commit.rb

Instance Attribute Summary collapse

Attributes inherited from GitObject

#id, #repository

Instance Method Summary collapse

Methods inherited from GitObject

#==, factory, #git_object, inherited

Constructor Details

#initialize(options = {}) ⇒ Commit

Returns a new instance of Commit.


6
7
8
9
10
11
12
13
14
# File 'lib/gitrb/commit.rb', line 6

def initialize(options = {})
  super(options)
  @parents = [options[:parents]].flatten.compact
  @tree = options[:tree]
  @author = options[:author]
  @committer = options[:committer]
  @message = options[:message]
  parse(options[:data]) if options[:data]
end

Instance Attribute Details

#authorObject

Returns the value of attribute author


4
5
6
# File 'lib/gitrb/commit.rb', line 4

def author
  @author
end

#committerObject

Returns the value of attribute committer


4
5
6
# File 'lib/gitrb/commit.rb', line 4

def committer
  @committer
end

#messageObject

Returns the value of attribute message


4
5
6
# File 'lib/gitrb/commit.rb', line 4

def message
  @message
end

#parentsObject

Returns the value of attribute parents


4
5
6
# File 'lib/gitrb/commit.rb', line 4

def parents
  @parents
end

#treeObject

Returns the value of attribute tree


4
5
6
# File 'lib/gitrb/commit.rb', line 4

def tree
  @tree
end

Instance Method Details

#dateObject


20
21
22
# File 'lib/gitrb/commit.rb', line 20

def date
  (committer && committer.date) || (author && author.date)
end

#dumpObject


29
30
31
32
33
34
35
36
# File 'lib/gitrb/commit.rb', line 29

def dump
  [ "tree #{tree.id}",
    @parents.map { |p| "parent #{p.id}" },
    "author #{author.dump}",
    "committer #{committer.dump}",
    '',
    message ].flatten.join("\n")
end

#saveObject


24
25
26
27
# File 'lib/gitrb/commit.rb', line 24

def save
  repository.put(self)
  id
end

#to_sObject


38
39
40
# File 'lib/gitrb/commit.rb', line 38

def to_s
  id
end

#typeObject


16
17
18
# File 'lib/gitrb/commit.rb', line 16

def type
  :commit
end