Class: Git::Object::Commit
Overview
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.
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/git/object.rb', line 206
def initialize(base, sha, init = nil)
super(base, sha)
@tree = nil
@parents = nil
@author = nil
@committer = nil
@message = nil
return unless init
from_data(init)
end
|
Instance Method Details
#author
243
244
245
246
|
# File 'lib/git/object.rb', line 243
def author
check_commit
@author
end
|
#author_date
248
249
250
|
# File 'lib/git/object.rb', line 248
def author_date
author.date
end
|
#commit? ⇒ Boolean
284
285
286
|
# File 'lib/git/object.rb', line 284
def commit?
true
end
|
#committer
253
254
255
256
|
# File 'lib/git/object.rb', line 253
def committer
check_commit
@committer
end
|
#committer_date
Also known as:
date
258
259
260
|
# File 'lib/git/object.rb', line 258
def committer_date
committer.date
end
|
#diff_parent
263
264
265
|
# File 'lib/git/object.rb', line 263
def diff_parent
diff(parent)
end
|
#from_data(data)
275
276
277
278
279
280
281
282
|
# File 'lib/git/object.rb', line 275
def from_data(data)
@sha ||= data['sha']
@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
|
#gtree
227
228
229
230
|
# File 'lib/git/object.rb', line 227
def gtree
check_commit
Tree.new(@base, @tree)
end
|
#message
218
219
220
221
|
# File 'lib/git/object.rb', line 218
def message
check_commit
@message
end
|
#name
223
224
225
|
# File 'lib/git/object.rb', line 223
def name
object_repository.name_rev(sha)
end
|
#parent
232
233
234
|
# File 'lib/git/object.rb', line 232
def parent
parents.first
end
|
#parents
array of all parent commits
237
238
239
240
|
# File 'lib/git/object.rb', line 237
def parents
check_commit
@parents
end
|
#set_commit(data)
rubocop:disable Naming/AccessorMethodName
267
268
269
270
271
272
273
|
# File 'lib/git/object.rb', line 267
def set_commit(data) Git::Deprecation.warn(
'Git::Object::Commit#set_commit is deprecated and will be removed in a future version. ' \
'Use #from_data instead.'
)
from_data(data)
end
|