-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
153 additions
and
54 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
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,57 @@ | ||
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 | ||
|
||
if config.is_none() { | ||
return Ok(None); | ||
} | ||
|
||
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(()) | ||
} |
Oops, something went wrong.