Skip to contentSkip to conversation

gitweb: Recognize *-to and Closes/Fixes trailers

PATCH In review Emma Brooks 2 participants 3 messages Apr 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Recognize *-to and Closes/Fixes trailers

Commit trailers like "Thanks-to:", "Fixes:", and "Closes:" are fairly common, but gitweb didn't highlight them like other trailers.

---
 gitweb/gitweb.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gitweb/gitweb.perl +1 -1
index 1a02a1242d..0959a782ec 100755
@@ -4641,7 +4641,7 @@ sub git_print_log {
 	# print log
 	my $skip_blank_line = 0;
 	foreach my $line (@$log) {
-		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-[Bb]y|C[Cc]): /) {
+		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-([Bb]y|[Tt]o)|C[Cc]|(Clos|Fix)es): /) {
 			if (! $opts{'-remove_signoff'}) {
 				print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
 				$skip_blank_line = 1;
#1 lore raw
Quoted 2 lines · Emma Brooks

Commit trailers like "Thanks-to:", "Fixes:", and "Closes:" are fairly common, but gitweb didn't highlight them like other trailers.

Did you also sneak "cc" in without documenting/justifying?

When the re becomes this complex, it may not be a bad idea to switch to "/ ignore most whitespaces /x" style for readability.

gitweb/gitweb.perl sub git_print_log { · line 4644

Quoted 2 lines
gitweb/gitweb.perl +1 -1
-		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-[Bb]y|C[Cc]): /) {
+		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-([Bb]y|[Tt]o)|C[Cc]|(Clos|Fix)es): /) {
		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-([Bb]y|[Tt]o) |
				    C[Cc] | Closes | Fixes ):\s /x) { 

Well, I am sloppy and did not make it all that easier to read.

More experienced Perl folks certainly would be able to teach us a much better convention to format things like this more readble.

#2 lore raw
Quoted 1 line · Junio C Hamano

Did you also sneak "cc" in without documenting/justifying?

No, that was already there in the original, before the colon:

Quoted 2 lines
Quoted 2 lines
gitweb/gitweb.perl +1 -1
-		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-[Bb]y|C[Cc]): /) {
+		if ($line =~ m/^\s*([A-Z][-A-Za-z]*-([Bb]y|[Tt]o)|C[Cc]|(Clos|Fix)es): /) {