-
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.
- Loading branch information
1 parent
df574c1
commit b264de0
Showing
5 changed files
with
119 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::config::ConvertedToDraftConfig; | ||
use crate::github::{IssuesAction, IssuesEvent, Label}; | ||
use crate::handlers::Context; | ||
|
||
pub(crate) struct ConvertedToDraftInput {} | ||
|
||
pub(crate) async fn parse_input( | ||
_ctx: &Context, | ||
event: &IssuesEvent, | ||
_config: Option<&ConvertedToDraftConfig>, | ||
) -> Result<Option<ConvertedToDraftInput>, String> { | ||
// PR author requests a review from one of the assignees | ||
|
||
match &event.action { | ||
IssuesAction::ConvertedToDraft => Ok(Some(ConvertedToDraftInput {})), | ||
_ => Ok(None), | ||
} | ||
} | ||
|
||
pub(crate) async fn handle_input( | ||
ctx: &Context, | ||
config: &ConvertedToDraftConfig, | ||
event: &IssuesEvent, | ||
ConvertedToDraftInput {}: ConvertedToDraftInput, | ||
) -> 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(()) | ||
} |
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,44 @@ | ||
use crate::config::ReadyForReviewConfig; | ||
use crate::github::{IssuesAction, IssuesEvent, Label}; | ||
use crate::handlers::Context; | ||
|
||
pub(crate) struct ReadyForReviewInput {} | ||
|
||
pub(crate) async fn parse_input( | ||
_ctx: &Context, | ||
event: &IssuesEvent, | ||
_config: Option<&ReadyForReviewConfig>, | ||
) -> Result<Option<ReadyForReviewInput>, String> { | ||
// PR author requests a review from one of the assignees | ||
|
||
match &event.action { | ||
IssuesAction::ReadyForReview => Ok(Some(ReadyForReviewInput {})), | ||
_ => Ok(None), | ||
} | ||
} | ||
|
||
pub(crate) async fn handle_input( | ||
ctx: &Context, | ||
config: &ReadyForReviewConfig, | ||
event: &IssuesEvent, | ||
ReadyForReviewInput {}: ReadyForReviewInput, | ||
) -> 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(()) | ||
} |