Skip to content

Commit 31100ff

Browse files
Treat PR reviews as pull requests (#1619)
1 parent 1552914 commit 31100ff

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use interactions::ErrorComment;
99
use std::fmt;
1010
use tracing as log;
1111

12+
use crate::github::PullRequestDetails;
13+
1214
pub mod actions;
1315
pub mod agenda;
1416
mod changelogs;
@@ -100,12 +102,18 @@ pub async fn webhook(
100102
) -> Result<bool, WebhookError> {
101103
let event = match event {
102104
EventName::PullRequestReview => {
103-
let payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
105+
let mut payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
104106
.context("PullRequestReview failed to deserialize")
105107
.map_err(anyhow::Error::from)?;
106108

107109
log::info!("handling pull request review comment {:?}", payload);
108110

111+
// Github doesn't send a pull_request field nested into the
112+
// pull_request field, so we need to adjust the deserialized result
113+
// to preserve that this event came from a pull request (since it's
114+
// a PR review, that's obviously the case).
115+
payload.pull_request.pull_request = Some(PullRequestDetails {});
116+
109117
// Treat pull request review comments exactly like pull request
110118
// review comments.
111119
github::Event::IssueComment(github::IssueCommentEvent {
@@ -125,10 +133,16 @@ pub async fn webhook(
125133
})
126134
}
127135
EventName::PullRequestReviewComment => {
128-
let payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
136+
let mut payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
129137
.context("PullRequestReview(Comment) failed to deserialize")
130138
.map_err(anyhow::Error::from)?;
131139

140+
// Github doesn't send a pull_request field nested into the
141+
// pull_request field, so we need to adjust the deserialized result
142+
// to preserve that this event came from a pull request (since it's
143+
// a PR review, that's obviously the case).
144+
payload.issue.pull_request = Some(PullRequestDetails {});
145+
132146
log::info!("handling pull request review comment {:?}", payload);
133147

134148
// Treat pull request review comments exactly like pull request

0 commit comments

Comments
 (0)