File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,28 @@ Commit_parents__get__(Commit *self)
199
199
return list ;
200
200
}
201
201
202
+ PyDoc_STRVAR (Commit_parent_ids__doc__ , "The list of parent commits' ids." );
203
+
204
+ PyObject *
205
+ Commit_parent_ids__get__ (Commit * self )
206
+ {
207
+ unsigned int i , parent_count ;
208
+ const git_oid * id ;
209
+ PyObject * list ;
210
+
211
+ parent_count = git_commit_parentcount (self -> commit );
212
+ list = PyList_New (parent_count );
213
+ if (!list )
214
+ return NULL ;
215
+
216
+ for (i = 0 ; i < parent_count ; i ++ ) {
217
+ id = git_commit_parent_id (self -> commit , i );
218
+ PyList_SET_ITEM (list , i , git_oid_to_python (id ));
219
+ }
220
+
221
+ return list ;
222
+ }
223
+
202
224
PyGetSetDef Commit_getseters [] = {
203
225
GETTER (Commit , message_encoding ),
204
226
GETTER (Commit , message ),
@@ -210,6 +232,7 @@ PyGetSetDef Commit_getseters[] = {
210
232
GETTER (Commit , tree ),
211
233
GETTER (Commit , tree_id ),
212
234
GETTER (Commit , parents ),
235
+ GETTER (Commit , parent_ids ),
213
236
{NULL }
214
237
};
215
238
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ def test_new_commit(self):
95
95
self .assertEqual (Oid (hex = tree ), commit .tree_id )
96
96
self .assertEqual (1 , len (commit .parents ))
97
97
self .assertEqual (COMMIT_SHA , commit .parents [0 ].hex )
98
+ self .assertEqual (Oid (hex = COMMIT_SHA ), commit .parent_ids [0 ])
98
99
99
100
def test_new_commit_encoding (self ):
100
101
repo = self .repo
@@ -122,6 +123,7 @@ def test_new_commit_encoding(self):
122
123
self .assertEqual (Oid (hex = tree ), commit .tree_id )
123
124
self .assertEqual (1 , len (commit .parents ))
124
125
self .assertEqual (COMMIT_SHA , commit .parents [0 ].hex )
126
+ self .assertEqual (Oid (hex = COMMIT_SHA ), commit .parent_ids [0 ])
125
127
126
128
def test_modify_commit (self ):
127
129
message = 'New commit.\n \n Message.\n '
You can’t perform that action at this time.
0 commit comments