File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+
6
+ namespace Git . hub
7
+ {
8
+ public class Ref
9
+ {
10
+ public string Url { get ; private set ; }
11
+ public string Sha { get ; private set ; }
12
+ }
13
+
14
+ public class PullRequestCommit
15
+ {
16
+ public string Sha { get ; private set ; }
17
+ public string Url { get ; private set ; }
18
+ public User Author { get ; private set ; }
19
+ public User Committer { get ; private set ; }
20
+ public List < Ref > Parents { get ; private set ; }
21
+ public Commit Commit { get ; private set ; }
22
+ }
23
+
24
+ public class CommitAuthor
25
+ {
26
+ public string Name { get ; private set ; }
27
+ public string Email { get ; private set ; }
28
+ public DateTime Date { get ; private set ; }
29
+ }
30
+
31
+ // Not too sure this is the same for normal commits.
32
+ public class Commit
33
+ {
34
+ public string Url { get ; private set ; }
35
+ public CommitAuthor Author { get ; private set ; }
36
+ public CommitAuthor Committer { get ; private set ; }
37
+ public string Message { get ; private set ; }
38
+ public Ref Tree { get ; private set ; }
39
+ }
40
+ }
Original file line number Diff line number Diff line change 40
40
<ItemGroup >
41
41
<Compile Include =" Branch.cs" />
42
42
<Compile Include =" Client.cs" />
43
+ <Compile Include =" Commit.cs" />
43
44
<Compile Include =" OAuth2Helper.cs" />
44
45
<Compile Include =" Organization.cs" />
45
46
<Compile Include =" Properties\AssemblyInfo.cs" />
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using RestSharp ;
3
+ using System . Collections . Generic ;
2
4
3
5
namespace Git . hub
4
6
{
@@ -15,6 +17,11 @@ public class PullRequestInfo
15
17
/// </summary>
16
18
public class PullRequest
17
19
{
20
+ /// <summary>
21
+ /// Repository to which this pull request belongs.
22
+ /// </summary>
23
+ public Repository Repository { get ; internal set ; }
24
+
18
25
/// <summary>
19
26
/// ID of the pull request
20
27
/// </summary>
@@ -65,5 +72,17 @@ public class PullRequest
65
72
/// </summary>
66
73
public User MergedBy { get; private set; }
67
74
*/
75
+
76
+ internal RestClient _client ;
77
+
78
+ public List < PullRequestCommit > GetCommits ( )
79
+ {
80
+ var request = new RestRequest ( "/repos/{user}/{repo}/pulls/{pull}/commits" ) ;
81
+ request . AddUrlSegment ( "user" , Repository . Owner . Login ) ;
82
+ request . AddUrlSegment ( "repo" , Repository . Name ) ;
83
+ request . AddUrlSegment ( "pull" , Number . ToString ( ) ) ;
84
+
85
+ return _client . Get < List < PullRequestCommit > > ( request ) . Data ;
86
+ }
68
87
}
69
88
}
Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ public IList<PullRequest> GetPullRequests()
96
96
request . AddUrlSegment ( "user" , Owner . Login ) ;
97
97
request . AddUrlSegment ( "repo" , Name ) ;
98
98
99
- return _client . Get < List < PullRequest > > ( request ) . Data ;
99
+ var list = _client . Get < List < PullRequest > > ( request ) . Data ;
100
+ if ( list == null )
101
+ return null ;
102
+
103
+ list . ForEach ( pr => { pr . _client = _client ; pr . Repository = this ; } ) ;
104
+ return list ;
100
105
}
101
106
102
107
/// <summary>
@@ -111,7 +116,13 @@ public PullRequest GetPullRequest(int id)
111
116
request . AddUrlSegment ( "repo" , Name ) ;
112
117
request . AddUrlSegment ( "pull" , id . ToString ( ) ) ;
113
118
114
- return _client . Get < PullRequest > ( request ) . Data ;
119
+ var pullrequest = _client . Get < PullRequest > ( request ) . Data ;
120
+ if ( pullrequest == null )
121
+ return null ;
122
+
123
+ pullrequest . _client = _client ;
124
+ pullrequest . Repository = this ;
125
+ return pullrequest ;
115
126
}
116
127
117
128
#if _
You can’t perform that action at this time.
0 commit comments