From fc0b13079f780a8dcd33415880af6dd7d6536b01 Mon Sep 17 00:00:00 2001 From: pep Date: Wed, 4 Sep 2024 23:43:30 +0200 Subject: [PATCH] Add support for ForgejoHook::Issue Signed-off-by: pep --- src/hooks/forgejo.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/hooks/forgejo.rs b/src/hooks/forgejo.rs index c31d719..4929411 100644 --- a/src/hooks/forgejo.rs +++ b/src/hooks/forgejo.rs @@ -13,10 +13,36 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use crate::hooks::types::{Commit, Hook, Push, Repository, User}; +use crate::hooks::types::{Commit, Hook, Issue, IssueAction, Push, Repository, User}; use crate::Error; -pub use ::forgejo_hooks::Hook as ForgejoHook; +pub use ::forgejo_hooks::{Hook as ForgejoHook, Issue as FjIssue, IssueAction as FjIssueAction}; + +impl From for IssueAction { + fn from(other: FjIssueAction) -> IssueAction { + match other { + FjIssueAction::Opened => IssueAction::Open, + FjIssueAction::Edited => IssueAction::Update, + } + } +} + +impl From for Issue { + fn from(other: FjIssue) -> Issue { + Issue { + id: other.number, + action: Some(other.action.into()), + title: other.issue.title, + author: User { + name: other.issue.user.login, + }, + repository: Repository { + name: other.repository.name, + }, + url: None, + } + } +} impl TryFrom for Hook { type Error = Error; @@ -42,6 +68,7 @@ impl TryFrom for Hook { name: push.pusher.username, }, }), + ForgejoHook::Issue(issue) => Hook::Issue(issue.into()), _ => return Err(Error::UnsupportedHookConversion), }) }