diff --git a/src/webhook.rs b/src/webhook.rs index a09d5dd..946697e 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -19,22 +19,31 @@ use log::debug; pub fn format_webhook(wh: &WebHook) -> Option { Some(match wh { WebHook::Push(push) => { - let mut text = format!( - "{} pushed {} commits to {} branch {}", - push.user_name, - push.commits.len(), - push.project.name, - push.ref_ - ); - for commit in &push.commits { - match commit.message.lines().nth(0) { - Some(subject) => { - text = format!("{}\n• {} <{}>", text, subject, commit.url); - } - None => {} - } - } - text + if push.commits.len() != 0 { + let mut text = format!( + "{} pushed {} commits to {} branch {}", + push.user_name, + push.commits.len(), + push.project.name, + push.ref_, + ); + for commit in &push.commits { + match commit.message.lines().nth(0) { + Some(subject) => { + text = format!("{}\n• {} <{}>", text, subject, commit.url); + } + None => {} + } + } + text + } else { + format!( + "{} deleted branch {} from {}", + push.user_name, + push.ref_, + push.project.name, + ) + } } WebHook::Issue(issue) => { let action = match issue.object_attributes.action {