-
Notifications
You must be signed in to change notification settings - Fork 85
Add review_submitted handler which changes labels after a review #1379
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::github::{Issue, IssueCommentAction, IssueCommentEvent, Label, PullRequestReviewState}; | ||
use crate::{config::ReviewSubmittedConfig, github::Event, handlers::Context}; | ||
|
||
pub(crate) async fn handle( | ||
ctx: &Context, | ||
event: &Event, | ||
config: &ReviewSubmittedConfig, | ||
) -> anyhow::Result<()> { | ||
if let Event::IssueComment( | ||
event | ||
@ | ||
IssueCommentEvent { | ||
action: IssueCommentAction::Created, | ||
issue: Issue { | ||
pull_request: Some(_), | ||
.. | ||
}, | ||
.. | ||
}, | ||
) = event | ||
{ | ||
if event.comment.pr_review_state != PullRequestReviewState::ChangesRequested { | ||
return Ok(()); | ||
} | ||
|
||
if event.issue.assignees.contains(&event.comment.user) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should only do this for "Request Changes". I'm not sure how to interpret a simple "comment" review that has no "inclination". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, changed it |
||
let labels = event | ||
.issue | ||
.labels() | ||
.iter() | ||
// Remove review related labels | ||
.filter(|label| !config.review_labels.contains(&label.name)) | ||
.cloned() | ||
// Add waiting on author label | ||
.chain(std::iter::once(Label { | ||
name: config.reviewed_label.clone(), | ||
})); | ||
event | ||
.issue | ||
.set_labels(&ctx.github, labels.collect()) | ||
.await?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this may have broken deserialization of issue comments -- I'm filing a fix now.