From 06e5ecf90d6583fe66286da2e2fdd4873fec1311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 7 Jun 2023 13:27:44 +0200 Subject: [PATCH] Attempt at making hooks less verbose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- src/webhook.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/webhook.rs b/src/webhook.rs index 53b27e1..42f5bb3 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -27,7 +27,8 @@ pub fn format_webhook(wh: &WebHook) -> Option { push.commits.len(), push.ref_, ); - for commit in &push.commits { + // Display max 3 commits + for commit in push.commits.clone().into_iter().take(3) { match commit.message.lines().nth(0) { Some(subject) => { text = format!("{}\n• {} <{}>", text, subject, commit.url); @@ -37,15 +38,13 @@ pub fn format_webhook(wh: &WebHook) -> Option { } text } else { - format!( - "[{}] {} deleted branch {}", - push.project.name, push.user_name, push.ref_, - ) + // Ignore: Branch got deleted + return None; } } WebHook::Issue(issue) => { let action = match issue.object_attributes.action { - Some(IssueAction::Update) => "updated", + Some(IssueAction::Update) => return None, Some(IssueAction::Open) => "opened", Some(IssueAction::Close) => "closed", Some(IssueAction::Reopen) => "reopened", @@ -68,7 +67,7 @@ pub fn format_webhook(wh: &WebHook) -> Option { } WebHook::MergeRequest(merge_req) => { let action = match merge_req.object_attributes.action { - Some(MergeRequestAction::Update) => "updated", + Some(MergeRequestAction::Update) => return None, Some(MergeRequestAction::Open) => "opened", Some(MergeRequestAction::Close) => "closed", Some(MergeRequestAction::Reopen) => "reopened",