Class: Git::Object::Commit
Instance Attribute Summary
#mode, #objectish, #size, #type
Instance Method Summary
collapse
#archive, #blob?, #contents, #contents_array, #diff, #grep, #log, #sha, #tag?, #to_s, #tree?
Constructor Details
#initialize(base, sha, init = nil) ⇒ Commit
Returns a new instance of Commit.
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/git/object.rb', line 151
def initialize(base, sha, init = nil)
super(base, sha)
@tree = nil
@parents = nil
@author = nil
@committer = nil
@message = nil
if init
set_commit(init)
end
end
|
Instance Method Details
188
189
190
191
|
# File 'lib/git/object.rb', line 188
def author
check_commit
@author
end
|
#author_date ⇒ Object
193
194
195
|
# File 'lib/git/object.rb', line 193
def author_date
author.date
end
|
#commit? ⇒ Boolean
223
224
225
|
# File 'lib/git/object.rb', line 223
def commit?
true
end
|
#committer ⇒ Object
198
199
200
201
|
# File 'lib/git/object.rb', line 198
def committer
check_commit
@committer
end
|
#committer_date ⇒ Object
Also known as:
date
203
204
205
|
# File 'lib/git/object.rb', line 203
def committer_date
committer.date
end
|
#diff_parent ⇒ Object
208
209
210
|
# File 'lib/git/object.rb', line 208
def diff_parent
diff(parent)
end
|
172
173
174
175
|
# File 'lib/git/object.rb', line 172
def gtree
check_commit
Tree.new(@base, @tree)
end
|
163
164
165
166
|
# File 'lib/git/object.rb', line 163
def message
check_commit
@message
end
|
168
169
170
|
# File 'lib/git/object.rb', line 168
def name
@base.lib.namerev(sha)
end
|
177
178
179
|
# File 'lib/git/object.rb', line 177
def parent
parents.first
end
|
array of all parent commits
182
183
184
185
|
# File 'lib/git/object.rb', line 182
def parents
check_commit
@parents
end
|
#set_commit(data) ⇒ Object
212
213
214
215
216
217
218
219
220
221
|
# File 'lib/git/object.rb', line 212
def set_commit(data)
if data['sha']
@sha = data['sha']
end
@committer = Git::Author.new(data['committer'])
@author = Git::Author.new(data['author'])
@tree = Git::Object::Tree.new(@base, data['tree'])
@parents = data['parent'].map{ |sha| Git::Object::Commit.new(@base, sha) }
@message = data['message'].chomp
end
|