File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -39,9 +39,11 @@ NS_ASSUME_NONNULL_BEGIN
39
39
40
40
@interface GTCommit : GTObject {}
41
41
42
+ @property (nonatomic , readonly , strong ) GTOID *OID;
42
43
@property (nonatomic , readonly , strong ) GTSignature * _Nullable author;
43
44
@property (nonatomic , readonly , strong ) GTSignature * _Nullable committer;
44
45
@property (nonatomic , readonly , copy ) NSArray <GTCommit *> *parents;
46
+ @property (nonatomic , readonly , copy ) NSArray <GTOID *> *parentOIDs;
45
47
@property (nonatomic , readonly ) NSString * _Nullable message;
46
48
@property (nonatomic , readonly ) NSString *messageDetails;
47
49
@property (nonatomic , readonly ) NSString *messageSummary;
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ - (git_commit *)git_commit {
53
53
54
54
#pragma mark API
55
55
56
+ - (GTOID *)OID {
57
+ return [GTOID oidWithGitOid: git_commit_id (self .git_commit)];
58
+ }
59
+
56
60
- (NSString *)message {
57
61
const char *s = git_commit_message (self.git_commit );
58
62
if (s == NULL ) return nil ;
@@ -117,6 +121,19 @@ - (BOOL)isMerge {
117
121
return git_commit_parentcount (self.git_commit ) > 1 ;
118
122
}
119
123
124
+ - (NSArray <GTOID *> *)parentOIDs {
125
+ unsigned numberOfParents = git_commit_parentcount (self.git_commit );
126
+ NSMutableArray <GTOID *> *parents = [NSMutableArray arrayWithCapacity: numberOfParents];
127
+
128
+ for (unsigned i = 0 ; i < numberOfParents; i++) {
129
+ const git_oid *parent = git_commit_parent_id (self.git_commit , i);
130
+
131
+ [parents addObject: [GTOID oidWithGitOid: parent]];
132
+ }
133
+
134
+ return parents;
135
+ }
136
+
120
137
- (NSArray *)parents {
121
138
unsigned numberOfParents = git_commit_parentcount (self.git_commit );
122
139
NSMutableArray *parents = [NSMutableArray arrayWithCapacity: numberOfParents];
Original file line number Diff line number Diff line change 31
31
expect (commit).to (beAnInstanceOf (GTCommit.class ));
32
32
expect (commit.type ).to (equal (@" commit" ));
33
33
expect (commit.SHA ).to (equal (commitSHA));
34
+ expect (commit.OID ).to (equal ([GTOID oidWithSHA: commitSHA]));
34
35
35
36
expect (commit.message ).to (equal (@" testing\n " ));
36
37
expect (commit.messageSummary ).to (equal (@" testing" ));
60
61
expect (commit).notTo (beNil ());
61
62
expect (error).to (beNil ());
62
63
63
- expect (@(commit.parents .count )).to (equal (@2 ));
64
+ NSArray *commitOIDs = @[@" c47800c7266a2be04c571c04d5a6614691ea99bd" , @" 9fd738e8f7967c078dceed8190330fc8648ee56a" ];
65
+ NSArray *commitParents = commit.parentOIDs ;
66
+ expect (@(commitParents.count )).to (equal (@(commitOIDs.count )));
67
+ expect ([commitParents valueForKey: @" SHA" ]).to (equal (commitOIDs));
68
+
69
+ commitParents = commit.parents ;
70
+ expect (@(commitParents.count )).to (equal (@(commitOIDs.count )));
71
+ expect ([commitParents valueForKeyPath: @" OID.SHA" ]).to (equal (commitOIDs));
64
72
});
65
73
66
74
it (@" can identify merges" , ^{
You can’t perform that action at this time.
0 commit comments