Better refname parsing
This commit is contained in:
parent
d74c30132c
commit
eb5bdc3fd5
18
src/main.rs
18
src/main.rs
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user