fix: only show first line on commit messages (#696)
Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
@@ -688,11 +688,23 @@ const LIGHT_ORANGE: &str = "#d9916d";
|
|||||||
// for future use
|
// for future use
|
||||||
// const WHITE: &str = "#c3e1c3";
|
// const WHITE: &str = "#c3e1c3";
|
||||||
|
|
||||||
fn shorten_text(text: &str, length: usize) -> String {
|
fn shorten_single_line_text(text: &str, length: usize) -> String {
|
||||||
if text.len() < length {
|
if text.contains('\n') {
|
||||||
text.to_string()
|
let text = text.split('\n').next().unwrap();
|
||||||
|
|
||||||
|
format!("{}...", &text[..text.len().min(length) - 3])
|
||||||
|
} else if text.len() > length {
|
||||||
|
format!("{}...", &text[..length - 3])
|
||||||
} else {
|
} else {
|
||||||
format!("{}...", &text[0..length])
|
text.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shorten_text(text: &str, length: usize) -> String {
|
||||||
|
if text.len() >= length {
|
||||||
|
format!("{}...", &text[..length - 3])
|
||||||
|
} else {
|
||||||
|
text.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,7 +835,7 @@ pub async fn webhook_execute_github(
|
|||||||
"[`{}`]({}) {} - {}",
|
"[`{}`]({}) {} - {}",
|
||||||
&commit.id[0..=7],
|
&commit.id[0..=7],
|
||||||
commit.url,
|
commit.url,
|
||||||
shorten_text(&commit.message, 50),
|
shorten_single_line_text(&commit.message, 50),
|
||||||
commit.author.name
|
commit.author.name
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user