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.
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/git/object.rb', line 149
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
186
187
188
189
|
# File 'lib/git/object.rb', line 186
def author
check_commit
@author
end
|
#author_date ⇒ Object
191
192
193
|
# File 'lib/git/object.rb', line 191
def author_date
author.date
end
|
#commit? ⇒ Boolean
221
222
223
|
# File 'lib/git/object.rb', line 221
def commit?
true
end
|
#committer ⇒ Object
196
197
198
199
|
# File 'lib/git/object.rb', line 196
def committer
check_commit
@committer
end
|
#committer_date ⇒ Object
Also known as:
date
201
202
203
|
# File 'lib/git/object.rb', line 201
def committer_date
committer.date
end
|
#diff_parent ⇒ Object
206
207
208
|
# File 'lib/git/object.rb', line 206
def diff_parent
diff(parent)
end
|
170
171
172
173
|
# File 'lib/git/object.rb', line 170
def gtree
check_commit
Tree.new(@base, @tree)
end
|
161
162
163
164
|
# File 'lib/git/object.rb', line 161
def message
check_commit
@message
end
|
166
167
168
|
# File 'lib/git/object.rb', line 166
def name
@base.lib.namerev(sha)
end
|
175
176
177
|
# File 'lib/git/object.rb', line 175
def parent
parents.first
end
|
array of all parent commits
180
181
182
183
|
# File 'lib/git/object.rb', line 180
def parents
check_commit
@parents
end
|
#set_commit(data) ⇒ Object
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/git/object.rb', line 210
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
|