-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1733 from WaffleLapkin/review-requested
Allow switching prs to waiting on review when author has requested a review from an assignee
- Loading branch information
Showing
7 changed files
with
94 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use crate::config::ReviewRequestedConfig; | ||
use crate::github::{IssuesAction, IssuesEvent, Label}; | ||
use crate::handlers::Context; | ||
|
||
pub(crate) struct ReviewRequestedInput {} | ||
|
||
pub(crate) async fn parse_input( | ||
_ctx: &Context, | ||
event: &IssuesEvent, | ||
_config: Option<&ReviewRequestedConfig>, | ||
) -> Result<Option<ReviewRequestedInput>, String> { | ||
// PR author requests a review from one of the assignees | ||
|
||
let IssuesAction::ReviewRequested { requested_reviewer } = &event.action else { | ||
return Ok(None); | ||
}; | ||
|
||
if event.sender != event.issue.user { | ||
return Ok(None); | ||
} | ||
|
||
if !event.issue.assignees.contains(requested_reviewer) { | ||
return Ok(None); | ||
} | ||
|
||
Ok(Some(ReviewRequestedInput {})) | ||
} | ||
|
||
pub(crate) async fn handle_input( | ||
ctx: &Context, | ||
config: &ReviewRequestedConfig, | ||
event: &IssuesEvent, | ||
ReviewRequestedInput {}: ReviewRequestedInput, | ||
) -> anyhow::Result<()> { | ||
event | ||
.issue | ||
.add_labels( | ||
&ctx.github, | ||
config | ||
.add_labels | ||
.iter() | ||
.cloned() | ||
.map(|name| Label { name }) | ||
.collect(), | ||
) | ||
.await?; | ||
|
||
for label in &config.remove_labels { | ||
event.issue.remove_label(&ctx.github, label).await?; | ||
} | ||
|
||
Ok(()) | ||
} |