-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathPullRequest.cs
319 lines (268 loc) · 10.6 KB
/
PullRequest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Octokit.Internal;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class PullRequest
{
public PullRequest() { }
public PullRequest(int number)
{
Number = number;
}
public PullRequest(long id, string nodeId, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList<User> assignees, bool draft, bool? mergeable, MergeableState? mergeableState, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked, bool? maintainerCanModify, IReadOnlyList<User> requestedReviewers, IReadOnlyList<Team> requestedTeams, IReadOnlyList<Label> labels, LockReason? activeLockReason)
{
Id = id;
NodeId = nodeId;
Url = url;
HtmlUrl = htmlUrl;
DiffUrl = diffUrl;
PatchUrl = patchUrl;
IssueUrl = issueUrl;
StatusesUrl = statusesUrl;
Number = number;
State = state;
Title = title;
Body = body;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
ClosedAt = closedAt;
MergedAt = mergedAt;
Head = head;
Base = @base;
User = user;
Assignee = assignee;
Assignees = assignees;
Draft = draft;
Mergeable = mergeable;
MergeableState = mergeableState;
MergedBy = mergedBy;
MergeCommitSha = mergeCommitSha;
Comments = comments;
Commits = commits;
Additions = additions;
Deletions = deletions;
ChangedFiles = changedFiles;
Milestone = milestone;
Locked = locked;
MaintainerCanModify = maintainerCanModify;
RequestedReviewers = requestedReviewers;
RequestedTeams = requestedTeams;
Labels = labels;
ActiveLockReason = activeLockReason;
}
/// <summary>
/// The internal Id for this pull request (not the pull request number)
/// </summary>
public long Id { get; private set; }
/// <summary>
/// GraphQL Node Id
/// </summary>
public string NodeId { get; private set; }
/// <summary>
/// The URL for this pull request.
/// </summary>
public string Url { get; private set; }
/// <summary>
/// The URL for the pull request page.
/// </summary>
public string HtmlUrl { get; private set; }
/// <summary>
/// The URL for the pull request's diff (.diff) file.
/// </summary>
public string DiffUrl { get; private set; }
/// <summary>
/// The URL for the pull request's patch (.patch) file.
/// </summary>
public string PatchUrl { get; private set; }
/// <summary>
/// The URL for the specific pull request issue.
/// </summary>
public string IssueUrl { get; private set; }
/// <summary>
/// The URL for the pull request statuses.
/// </summary>
public string StatusesUrl { get; private set; }
/// <summary>
/// The pull request number.
/// </summary>
public int Number { get; private set; }
/// <summary>
/// Whether the pull request is open or closed. The default is <see cref="ItemState.Open"/>.
/// </summary>
public StringEnum<ItemState> State { get; private set; }
/// <summary>
/// Title of the pull request.
/// </summary>
public string Title { get; private set; }
/// <summary>
/// The body (content) contained within the pull request.
/// </summary>
public string Body { get; private set; }
/// <summary>
/// When the pull request was created.
/// </summary>
public DateTimeOffset CreatedAt { get; private set; }
/// <summary>
/// When the pull request was last updated.
/// </summary>
public DateTimeOffset UpdatedAt { get; private set; }
/// <summary>
/// When the pull request was closed.
/// </summary>
public DateTimeOffset? ClosedAt { get; private set; }
/// <summary>
/// When the pull request was merged.
/// </summary>
public DateTimeOffset? MergedAt { get; private set; }
/// <summary>
/// The HEAD reference for the pull request.
/// </summary>
public GitReference Head { get; private set; }
/// <summary>
/// The BASE reference for the pull request.
/// </summary>
public GitReference Base { get; private set; }
/// <summary>
/// The user who created the pull request.
/// </summary>
public User User { get; private set; }
/// <summary>
/// The user who is assigned the pull request.
/// </summary>
public User Assignee { get; private set; }
/// <summary>
///The multiple users this pull request is assigned to.
/// </summary>
public IReadOnlyList<User> Assignees { get; private set; }
/// <summary>
/// The milestone, if any, that this pull request is assigned to.
/// </summary>
public Milestone Milestone { get; private set; }
/// <summary>
/// Whether or not the pull request is in a draft state, and cannot be merged.
/// </summary>
public bool Draft { get; private set; }
/// <summary>
/// Whether or not the pull request has been merged.
/// </summary>
public bool Merged
{
get { return MergedAt.HasValue; }
}
/// <summary>
/// Whether or not the pull request can be merged.
/// </summary>
public bool? Mergeable { get; private set; }
/// <summary>
/// Provides extra information regarding the mergeability of the pull request.
/// </summary>
public StringEnum<MergeableState>? MergeableState { get; private set; }
/// <summary>
/// The user who merged the pull request.
/// </summary>
public User MergedBy { get; private set; }
/// <summary>
/// The value of this field changes depending on the state of the pull request.
/// Not Merged - the hash of the test commit used to determine mergeability.
/// Merged with merge commit - the hash of said merge commit.
/// Merged via squashing - the hash of the squashed commit added to the base branch.
/// Merged via rebase - the hash of the commit that the base branch was updated to.
/// </summary>
public string MergeCommitSha { get; private set; }
/// <summary>
/// Total number of comments contained in the pull request.
/// </summary>
public int Comments { get; private set; }
/// <summary>
/// Total number of commits contained in the pull request.
/// </summary>
public int Commits { get; private set; }
/// <summary>
/// Total number of additions contained in the pull request.
/// </summary>
public int Additions { get; private set; }
/// <summary>
/// Total number of deletions contained in the pull request.
/// </summary>
public int Deletions { get; private set; }
/// <summary>
/// Total number of files changed in the pull request.
/// </summary>
public int ChangedFiles { get; private set; }
/// <summary>
/// If the issue is locked or not
/// </summary>
public bool Locked { get; private set; }
/// <summary>
/// Whether maintainers of the base repository can push to the HEAD branch
/// </summary>
public bool? MaintainerCanModify { get; private set; }
/// <summary>
/// Users requested for review
/// </summary>
public IReadOnlyList<User> RequestedReviewers { get; private set; }
/// <summary>
/// Teams requested for review
/// </summary>
public IReadOnlyList<Team> RequestedTeams { get; private set; }
public IReadOnlyList<Label> Labels { get; private set; }
/// <summary>
/// Reason that the conversation was locked
/// </summary>
public StringEnum<LockReason>? ActiveLockReason { get; private set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Number: {0} State: {1}", Number, State); }
}
}
/// <summary>
/// Provides extra information regarding the mergeability of a pull request
/// </summary>
public enum MergeableState
{
/// <summary>
/// Merge conflict. Merging is blocked.
/// </summary>
[Parameter(Value = "dirty")]
Dirty,
/// <summary>
/// Mergeability was not checked yet. Merging is blocked.
/// </summary>
[Parameter(Value = "unknown")]
Unknown,
/// <summary>
/// Failing/missing required status check. Merging is blocked.
/// </summary>
[Parameter(Value = "blocked")]
Blocked,
/// <summary>
/// Head branch is behind the base branch. Only if required status checks is enabled but loose policy is not. Merging is blocked.
/// </summary>
[Parameter(Value = "behind")]
Behind,
/// <summary>
/// Failing/pending commit status that is not part of the required status checks. Merging is still allowed.
/// </summary>
[Parameter(Value = "unstable")]
Unstable,
/// <summary>
/// GitHub Enterprise only, if a repo has custom pre-receive hooks. Merging is allowed.
/// </summary>
[Parameter(Value = "has_hooks")]
HasHooks,
/// <summary>
/// No conflicts, everything good. Merging is allowed.
/// </summary>
[Parameter(Value = "clean")]
Clean,
/// <summary>
/// Not ready for review. Merging is blocked.
/// </summary>
[Parameter(Value = "draft")]
Draft
}
}