From 559e1d37b23c113d7d5574bf708ca6e4a489a742 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 15 Oct 2023 12:48:24 +0200 Subject: [PATCH 1/3] Make `IssuesAction` into a dataful enum, to remove unwraps --- src/github.rs | 22 ++++++++++++++++------ src/handlers/autolabel.rs | 4 ++-- src/handlers/major_change.rs | 19 +++---------------- src/handlers/notify_zulip.rs | 18 ++++++++++-------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/github.rs b/src/github.rs index 496a214e..f46b8d55 100644 --- a/src/github.rs +++ b/src/github.rs @@ -911,7 +911,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, @@ -923,13 +923,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, @@ -940,13 +949,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