diff --git a/.env.sample b/.env.sample index 405d97dd..d79667d3 100644 --- a/.env.sample +++ b/.env.sample @@ -5,3 +5,9 @@ GITHUB_WEBHOOK_SECRET=MUST_BE_CONFIGURED # for logging, refer to this document: https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html # `RUSTC_LOG` is not required to run the application, but it makes local development easier # RUST_LOG=MUST_BE_CONFIGURED + +# If you are running a bot on non-rustbot account, +# this allows to configure that username which the bot will respond to. +# For example write blahblahblah here, if you want for this bot to +# respond to @blahblahblah claim. +# TRIAGEBOT_USERNAME=CAN_BE_CONFIGURED diff --git a/src/config.rs b/src/config.rs index 0b3d6233..2c81b988 100644 --- a/src/config.rs +++ b/src/config.rs @@ -30,6 +30,7 @@ pub(crate) struct Config { pub(crate) notify_zulip: Option, pub(crate) github_releases: Option, pub(crate) review_submitted: Option, + pub(crate) review_requested: Option, pub(crate) shortcut: Option, pub(crate) note: Option, pub(crate) mentions: Option, @@ -108,9 +109,9 @@ impl AssignConfig { #[derive(PartialEq, Eq, Debug, serde::Deserialize)] pub(crate) struct NoMergesConfig { - /// No action will be taken on PRs with these labels. + /// No action will be taken on PRs with these substrings in the title. #[serde(default)] - pub(crate) exclude_labels: Vec, + pub(crate) exclude_titles: Vec, /// Set these labels on the PR when merge commits are detected. #[serde(default)] pub(crate) labels: Vec, @@ -269,6 +270,12 @@ pub(crate) struct ReviewSubmittedConfig { pub(crate) reviewed_label: String, } +#[derive(PartialEq, Eq, Debug, serde::Deserialize)] +pub(crate) struct ReviewRequestedConfig { + pub(crate) remove_labels: Vec, + pub(crate) add_labels: Vec, +} + pub(crate) async fn get( gh: &GithubClient, repo: &Repository, @@ -437,6 +444,7 @@ mod tests { notify_zulip: None, github_releases: None, review_submitted: None, + review_requested: None, mentions: None, no_merges: None, validate_config: Some(ValidateConfig {}), diff --git a/src/github.rs b/src/github.rs index c36b8b10..373437ef 100644 --- a/src/github.rs +++ b/src/github.rs @@ -924,7 +924,7 @@ pub struct IssueCommentEvent { } #[derive(PartialEq, Eq, Debug, serde::Deserialize)] -#[serde(rename_all = "snake_case")] +#[serde(rename_all = "snake_case", tag = "action")] pub enum IssuesAction { Opened, Edited, @@ -936,13 +936,22 @@ pub enum IssuesAction { Reopened, Assigned, Unassigned, - Labeled, - Unlabeled, + Labeled { + /// The label added from the issue + label: Label, + }, + Unlabeled { + /// The label removed from the issue + label: Label, + }, Locked, Unlocked, Milestoned, Demilestoned, - ReviewRequested, + ReviewRequested { + /// The person requested to review the pull request + requested_reviewer: User, + }, ReviewRequestRemoved, ReadyForReview, Synchronize, @@ -953,13 +962,14 @@ pub enum IssuesAction { #[derive(Debug, serde::Deserialize)] pub struct IssuesEvent { + #[serde(flatten)] pub action: IssuesAction, #[serde(alias = "pull_request")] pub issue: Issue, pub changes: Option, pub repository: Repository, - /// Some if action is IssuesAction::Labeled, for example - pub label: Option