Unified · Split
| @@ -1,4 +1,5 @@ | |||
| 1 | use gix::{bstr::ByteSlice, url::Scheme, Url}; | 1 | use gix::{bstr::ByteSlice, url::Scheme, Url}; |
| 2 | use std::borrow::Cow; | ||
| 2 | 3 | ||
| 3 | use crate::{ | 4 | use crate::{ |
| 4 | changelog, | 5 | changelog, |
| @@ -397,8 +398,14 @@ fn format_oid(id: &gix::oid, link_mode: &Linkables) -> String { · 392 unmodified lines | |||
| 397 | } | 398 | } |
| 398 | } | 399 | } |
| 399 | 400 | ||
| 400 | fn capitalize_message_title(title: &String) -> String { | 401 | fn capitalize_message_title<'a>(title: impl Into<Cow<'a, str>>) -> Cow<'a, str> { |
| 401 | let mut v: Vec<char> = title.chars().collect(); | 402 | let mut title = title.into(); |
| 402 | v[0] = v[0].to_uppercase().nth(0).unwrap(); | 403 | let mut chars = title.chars(); |
| 403 | v.into_iter().collect() | 404 | if let Some(first) = chars |
| 405 | .next() | ||
| 406 | .and_then(|c| (c.to_uppercase().next() != Some(c)).then_some(c)) | ||
| 407 | { | ||
| 408 | *title.to_mut() = first.to_uppercase().chain(chars).collect(); | ||
| 409 | } | ||
| 410 | title | ||
| 404 | } | 411 | } |