Skip to content

Treat PR reviews as pull requests #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use interactions::ErrorComment;
use std::fmt;
use tracing as log;

use crate::github::PullRequestDetails;

pub mod actions;
pub mod agenda;
mod changelogs;
Expand Down Expand Up @@ -100,12 +102,18 @@ pub async fn webhook(
) -> Result<bool, WebhookError> {
let event = match event {
EventName::PullRequestReview => {
let payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
let mut payload = deserialize_payload::<github::PullRequestReviewEvent>(&payload)
.context("PullRequestReview failed to deserialize")
.map_err(anyhow::Error::from)?;

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

// Github doesn't send a pull_request field nested into the
// pull_request field, so we need to adjust the deserialized result
// to preserve that this event came from a pull request (since it's
// a PR review, that's obviously the case).
payload.pull_request.pull_request = Some(PullRequestDetails {});

// Treat pull request review comments exactly like pull request
// review comments.
github::Event::IssueComment(github::IssueCommentEvent {
Expand All @@ -125,10 +133,16 @@ pub async fn webhook(
})
}
EventName::PullRequestReviewComment => {
let payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
let mut payload = deserialize_payload::<github::PullRequestReviewComment>(&payload)
.context("PullRequestReview(Comment) failed to deserialize")
.map_err(anyhow::Error::from)?;

// Github doesn't send a pull_request field nested into the
// pull_request field, so we need to adjust the deserialized result
// to preserve that this event came from a pull request (since it's
// a PR review, that's obviously the case).
payload.issue.pull_request = Some(PullRequestDetails {});

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

// Treat pull request review comments exactly like pull request
Expand Down