Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-06-03 02:15:24 +02:00
parent 5f8b7d1c17
commit b8987f6eeb

View file

@ -19,31 +19,29 @@ use log::debug;
pub fn format_webhook(wh: &WebHook) -> Option<String> { pub fn format_webhook(wh: &WebHook) -> Option<String> {
Some(match wh { Some(match wh {
WebHook::Push(push) => { WebHook::Push(push) => {
if push.commits.len() != 0 { if push.commits.len() != 0 {
let mut text = format!( let mut text = format!(
"[{}] {} pushed {} commits branch {}", "[{}] {} pushed {} commits branch {}",
push.project.name, push.project.name,
push.user_name, push.user_name,
push.commits.len(), push.commits.len(),
push.ref_, push.ref_,
); );
for commit in &push.commits { for commit in &push.commits {
match commit.message.lines().nth(0) { match commit.message.lines().nth(0) {
Some(subject) => { Some(subject) => {
text = format!("{}\n{} <{}>", text, subject, commit.url); text = format!("{}\n{} <{}>", text, subject, commit.url);
} }
None => {} None => {}
} }
} }
text text
} else { } else {
format!( format!(
"[{}] {} deleted branch {}", "[{}] {} deleted branch {}",
push.project.name, push.project.name, push.user_name, push.ref_,
push.user_name, )
push.ref_, }
)
}
} }
WebHook::Issue(issue) => { WebHook::Issue(issue) => {
let action = match issue.object_attributes.action { let action = match issue.object_attributes.action {