webhook: Expose Note (comments) event

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

View file

@ -94,8 +94,31 @@ pub fn format_webhook(wh: &WebHook) -> Option<String> {
)
}
WebHook::Note(note) => {
println!("Note: {:?}", note);
return None;
if let Some(_) = note.snippet {
return None;
}
if let Some(commit) = &note.commit {
format!(
"[{}] {} commented on commit {:?} <{}>",
note.project.name, note.user.name, commit.id, commit.url,
)
} else if let Some(issue) = &note.issue {
format!(
"[{}] {} commented on issue {}: {} <{}>",
note.project.name,
note.user.name,
issue.iid,
issue.title,
note.object_attributes.url,
)
} else if let Some(mr) = &note.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);