Don't crash for unknown MR action

This commit is contained in:
xmppftw 2024-08-07 10:58:51 +02:00 committed by Maxime “pep” Buquet
parent f9e6b91451
commit f70b5f8aa1

View file

@ -40,7 +40,7 @@ pub fn format_hook(glh: &GitlabHook) -> Option<String> {
push.user_name, push.user_name,
push.ref_.strip_prefix("refs/tags/").unwrap_or("?!"), push.ref_.strip_prefix("refs/tags/").unwrap_or("?!"),
) )
}, }
GitlabHook::Push(push) => { GitlabHook::Push(push) => {
if push.ref_ != "refs/heads/main" { if push.ref_ != "refs/heads/main" {
// Ignore: Action not on 'main' branch // Ignore: Action not on 'main' branch
@ -99,7 +99,13 @@ pub fn format_hook(glh: &GitlabHook) -> Option<String> {
Some(MergeRequestAction::Reopen) => "reopened", Some(MergeRequestAction::Reopen) => "reopened",
Some(MergeRequestAction::Merge) => "merged", Some(MergeRequestAction::Merge) => "merged",
None => return None, None => return None,
_ => todo!(), _ => {
log::warn!(
"Unsupported merge request action: {:?}",
merge_req.object_attributes.action
);
return None;
}
}; };
format!( format!(
"[{}] {} {} merge request {}: {}{}", "[{}] {} {} merge request {}: {}{}",