From ed46dcd2796b9af6ba3f73d46a3141a88964ed11 Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Sun, 24 Jul 2022 13:17:19 +0800 Subject: [PATCH v1] gitweb: improve title_short shortening heuristics In order to shorten the title, some common domain prefixes can be detected and removed. However, the current regex matches those prefix anywhere in the title which makes it likely to remove it where it's not intended. To make that case less likely, make sure that the prefix is preceded by at least one whitespace and isn't followed by another whitespace. While at it, also add git:// and https:// to the list of detected and trimmed protocols. Signed-off-by: Julien Rouhaud --- gitweb/gitweb.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1835487ab2..18dd0b93fb 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3565,10 +3565,10 @@ sub parse_commit_text { $title =~ s/^Automatic //; $title =~ s/^merge (of|with) /Merge ... /i; if (length($title) > 50) { - $title =~ s/(http|rsync):\/\///; + $title =~ s/(git|http|https|rsync):\/\///; } if (length($title) > 50) { - $title =~ s/(master|www|rsync)\.//; + $title =~ s/\s+(master|www|rsync)\.([^\s])/ \2/; } if (length($title) > 50) { $title =~ s/kernel.org:?//; -- 2.37.0