From 5f8b7d1c17a2a146d3bb9841954fb9be5e33ac39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 3 Jun 2023 02:14:56 +0200 Subject: [PATCH] webhook: Expose Note (comments) event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- src/webhook.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/webhook.rs b/src/webhook.rs index 6c42527..8753822 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -94,8 +94,31 @@ pub fn format_webhook(wh: &WebHook) -> Option { ) } WebHook::Note(note) => { - println!("Note: {:?}", note); - return None; + if let Some(_) = note.snippet { + return None; + } + if let Some(commit) = ¬e.commit { + format!( + "[{}] {} commented on commit {:?} <{}>", + note.project.name, note.user.name, commit.id, commit.url, + ) + } else if let Some(issue) = ¬e.issue { + format!( + "[{}] {} commented on issue {}: {} <{}>", + note.project.name, + note.user.name, + issue.iid, + issue.title, + note.object_attributes.url, + ) + } else if let Some(mr) = ¬e.merge_request { + format!( + "[{}] {} commented on merge request {}: {} <{}>", + note.project.name, note.user.name, mr.iid, mr.title, note.object_attributes.url, + ) + } else { + unreachable!() + } } WebHook::Build(build) => { println!("Build: {:?}", build);