Better refname parsing

This commit is contained in:
Brian Tarricone 2023-09-16 01:04:11 -07:00
parent d74c30132c
commit eb5bdc3fd5

View File

@ -106,12 +106,18 @@ async fn ensure_matrix_room_joined(matrix_client: &Client, room_id: &OwnedRoomOr
fn build_gitlab_message(event: &GitlabEvent) -> String {
let project = event.project();
let refname = event
.r#ref()
.split('/')
.last()
.unwrap_or_else(|| event.r#ref())
.to_string();
let r = event.r#ref();
let refname = if r.starts_with("refs/") {
let parts = r.split('/').collect::<Vec<_>>();
if parts.len() > 2 {
parts.into_iter().skip(2).collect::<Vec<_>>().join("/").to_string()
} else {
drop(parts);
r.to_string()
}
} else {
r.to_string()
};
format!(
"*{}* {} **{}** [{}]({})",
project.path_with_namespace,