@@ -231,33 +231,61 @@ pub struct Label {
231
231
pub name : String ,
232
232
}
233
233
234
+ /// An issue or pull request.
235
+ ///
236
+ /// For convenience, since issues and pull requests share most of their
237
+ /// fields, this struct is used for both. The `pull_request` field can be used
238
+ /// to determine which it is. Some fields are only available on pull requests
239
+ /// (but not always, check the GitHub API for details).
234
240
#[ derive( Debug , serde:: Deserialize ) ]
235
241
pub struct Issue {
236
242
pub number : u64 ,
237
243
#[ serde( deserialize_with = "opt_string" ) ]
238
244
pub body : String ,
239
245
created_at : chrono:: DateTime < Utc > ,
240
246
pub updated_at : chrono:: DateTime < Utc > ,
247
+ /// The SHA for a merge commit.
248
+ ///
249
+ /// This field is complicated, see the [Pull Request
250
+ /// docs](https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request)
251
+ /// for details.
241
252
#[ serde( default ) ]
242
253
pub merge_commit_sha : Option < String > ,
243
254
pub title : String ,
255
+ /// The common URL for viewing this issue or PR.
256
+ ///
257
+ /// Example: `https://github.com/octocat/Hello-World/pull/1347`
244
258
pub html_url : String ,
245
259
pub user : User ,
246
260
pub labels : Vec < Label > ,
247
261
pub assignees : Vec < User > ,
262
+ /// This is true if this is a pull request.
263
+ ///
264
+ /// Note that this field does not come from GitHub. This is manually added
265
+ /// when the webhook arrives to help differentiate between an event
266
+ /// related to an issue versus a pull request.
248
267
#[ serde( default ) ]
249
268
pub pull_request : bool ,
269
+ /// Whether or not the pull request was merged.
250
270
#[ serde( default ) ]
251
271
pub merged : bool ,
252
272
#[ serde( default ) ]
253
273
pub draft : bool ,
254
- // API URL
274
+ /// The API URL for discussion comments.
275
+ ///
276
+ /// Example: `https://api.github.com/repos/octocat/Hello-World/issues/1347/comments`
255
277
comments_url : String ,
278
+ /// The repository for this issue.
279
+ ///
280
+ /// Note that this is constructed via the [`Issue::repository`] method.
281
+ /// It is not deserialized from the GitHub API.
256
282
#[ serde( skip) ]
257
283
repository : OnceCell < IssueRepository > ,
258
284
285
+ /// The base commit for a PR (the branch of the destination repo).
259
286
#[ serde( default ) ]
260
287
base : Option < CommitBase > ,
288
+ /// The head commit for a PR (the branch from the source repo).
261
289
#[ serde( default ) ]
262
290
head : Option < CommitBase > ,
263
291
}
@@ -794,6 +822,9 @@ pub enum PullRequestReviewAction {
794
822
Dismissed ,
795
823
}
796
824
825
+ /// A pull request review event.
826
+ ///
827
+ /// <https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request_review>
797
828
#[ derive( Debug , serde:: Deserialize ) ]
798
829
pub struct PullRequestReviewEvent {
799
830
pub action : PullRequestReviewAction ,
@@ -1211,11 +1242,21 @@ pub struct PushEvent {
1211
1242
sender : User ,
1212
1243
}
1213
1244
1245
+ /// An event triggered by a webhook.
1214
1246
#[ derive( Debug ) ]
1215
1247
pub enum Event {
1248
+ /// A Git branch or tag is created.
1216
1249
Create ( CreateEvent ) ,
1250
+ /// A comment on an issue or PR.
1251
+ ///
1252
+ /// Can be:
1253
+ /// - Regular comment on an issue or PR.
1254
+ /// - A PR review.
1255
+ /// - A comment on a PR review.
1217
1256
IssueComment ( IssueCommentEvent ) ,
1257
+ /// Activity on an issue or PR.
1218
1258
Issue ( IssuesEvent ) ,
1259
+ /// One or more commits are pushed to a repository branch or tag.
1219
1260
Push ( PushEvent ) ,
1220
1261
}
1221
1262
0 commit comments