@@ -67,6 +67,7 @@ type RepoData interface {
67
67
CommitByIndex (ref Ref , index uint ) (* Commit , error )
68
68
Commit (oid * Oid ) (* Commit , error )
69
69
CommitByOid (oidStr string ) (* Commit , error )
70
+ CommitParents (oid * Oid ) ([]* Commit , error )
70
71
AddCommitFilter (Ref , * CommitFilter ) error
71
72
RemoveCommitFilter (Ref ) error
72
73
DiffCommit (commit * Commit ) (* Diff , error )
@@ -1276,6 +1277,29 @@ func (repoData *RepositoryData) CommitByOid(oidStr string) (*Commit, error) {
1276
1277
return repoData .repoDataLoader .CommitByOid (oidStr )
1277
1278
}
1278
1279
1280
+ // CommitParents loads the parents of a commit
1281
+ func (repoData * RepositoryData ) CommitParents (oid * Oid ) (parentCommits []* Commit , err error ) {
1282
+ commit , err := repoData .repoDataLoader .Commit (oid )
1283
+ if err != nil {
1284
+ return
1285
+ }
1286
+
1287
+ parentCount := commit .commit .ParentCount ()
1288
+ var parentCommit * Commit
1289
+
1290
+ for i := uint (0 ); i < parentCount ; i ++ {
1291
+ parentOid := & Oid {commit .commit .ParentId (i )}
1292
+ parentCommit , err = repoData .Commit (parentOid )
1293
+ if err != nil {
1294
+ return
1295
+ }
1296
+
1297
+ parentCommits = append (parentCommits , parentCommit )
1298
+ }
1299
+
1300
+ return
1301
+ }
1302
+
1279
1303
// AddCommitFilter adds the filter to the specified ref
1280
1304
func (repoData * RepositoryData ) AddCommitFilter (ref Ref , commitFilter * CommitFilter ) error {
1281
1305
return repoData .refCommitSets .addCommitFilter (ref , commitFilter )
0 commit comments