Skip to contentSkip to conversation

gitweb - XMMS2 project customisations

PATCH In review Sham Chukoury 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb - XMMS2 project customisations

G'day.

I figured you folks might be interested in a number of modifications the XMMS2 team have made to gitweb. All the changes can be seen at http://git.xmms.se

1) Navbar refactoring (gitweb-xmms2navbar.diff)
The original idea was to add a link to our snapshots directory, in the navigation bar at the top of every gitweb page. The problem was that the code for producing the navbar HTML was mostly duplicated in various different places. I refactored the code so that a single 'git_navbar' subroutine is called every time gitweb needs a navbar. The patch itself probably needs some cleaning up: 1) I omitted the git_navbar call in one place, as the original navbar code there didn't look like the navbar code in other places, 2) there's a 'snapshot link' in the navbar which won't work unless gitweb-xmms2snapshots.diff is also applied ($snapshots_url isn't defined in gitweb-xmms2navbar.diff)

2) Commit tags support (gitweb-xmms2committags.diff)
We originally started using specific commit tags during the development of XMMS2 to facilitate the generation of changelogs at every release. This patch reformats commit descriptions containing 'BUG' or 'FEATURE' to produce hyperlinks to bug reports on our mantis bug tracker (http://bugs.xmms2.xmms.se), as well as linking to release information pages ('RELEASE' tag). You could adapt this patch to provide support for other custom tags. It might also be possible to cleverly integrate the committags and committags_shortlog subroutines into a single subroutine.. I couldn't figure it out easily enough - my Perl(+regexp)-fu isn't strong enough. ;)

3) Snapshot integration (gitweb-xmms2snapshots.diff & snapshot.cgi)
This patch makes it possible to easily produce snapshots of every commit in a git tree. Hyperlinks to 'snapshot' or 'latest snapshot' are added in various places. All you need is to have a CGI script to handle the request, with 'tree' and 'commit' parameters, where 'tree' refers to a git tree/repository and 'commit' is either a commit hash or 'HEAD'. I'm also attaching snapshot.cgi, the Python script we use to automagically generate and serve snapshot tarballs, as reference.

Hope someone finds these useful.. ;)
Cheers
-S

gitweb.cgi renamed from gitweb/gitweb.cgi +22 -5
@@ -40,6 +40,23 @@
 #my $projects_list = $projectroot;
 my $projects_list = "index/index.aux";
 
+# custom stuff - mantis/commit tags integration
+sub committags($){
+	my $a = shift;
+	$a =~ s!BUG\(([0-9]*)\)!<a href="http://bugs.xmms2.xmms.se/view.php?id=$1">BUG($1)</a>!g;
+	$a =~ s!FEATURE\(([0-9]*)\)!<a href="http://bugs.xmms2.xmms.se/view.php?id=$1">FEATURE($1)</a>!g;
+	$a =~ s!RELEASE: (.*)!RELEASE: <a href="http://wiki.xmms2.xmms.se/index.php/Release:$1">$1</a>!g;
+	return $a;
+}
+sub committags_shortlog($$){
+	my $a = shift;
+	my $href = shift;
+	$a =~ s!BUG\(([0-9]*)\)!</a><a href="http://bugs.xmms2.xmms.se/view.php?id=$1">BUG($1)</a><a class=\"list\" href=\"$href\">!g;
+	$a =~ s!FEATURE\(([0-9]*)\)!</a><a href="http://bugs.xmms2.xmms.se/view.php?id=$1">FEATURE($1)</a><a class=\"list\" href=\"$href\">!g;
+	$a =~ s!RELEASE: (.*)!RELEASE: <a href="http://wiki.xmms2.xmms.se/index.php/Release:$1">$1</a>!g;
+	return $a;
+}
+
 # input validation and dispatch
 my $action = $cgi->param('a');
 if (defined $action) {
@@ -655,7 +672,7 @@
 			$line =~ s/$hash_text/$link/;
 		}
 	}
-	return $line;
+	return committags($line);
 }
 
 sub date_str {
@@ -979,7 +996,7 @@
 			      "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
 			      "<td>" .
 			      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"},
-			      "<b>" . escapeHTML($co{'title_short'}) . "</b>") .
+			      "<b>" . committags_shortlog(escapeHTML($co{'title_short'}), "$my_uri?p=$project;a=commit;h=$commit") . "</b>") .
 			      "</td>\n" .
 			      "<td class=\"link\">" .
 			      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
@@ -1977,7 +1994,7 @@
 	      "<br/><br/>\n" .
 	      "</div>\n";
 	print "<div>\n" .
-	      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" .
+	      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, committags(escapeHTML($co{'title'}))) . "\n" .
 	      "</div>\n";
 	print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n";
 
@@ -2004,7 +2021,7 @@
 			print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
 			      "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
 			      "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
-			      escapeHTML(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
+			      committags(escapeHTML(chop_str($co{'title'}, 50))) . "</b>") . "</td>\n" .
 			      "<td class=\"link\">" .
 			      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
 			      " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file_name"}, "blob");
@@ -2230,7 +2247,7 @@
 		print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
 		      "<td><i>" . escapeHTML(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
 		      "<td>" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "<b>" .
-		      escapeHTML($co{'title_short'}) . "</b>") . "</td>\n" .
+		      committags_shortlog(escapeHTML($co{'title_short'}), "$my_uri?p=$project;a=commit;h=$commit") . "</b>") . "</td>\n" .
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
 		      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
gitweb.cgi renamed from gitweb/gitweb.cgi +74 -121

313 lines not on this page · raw message

gitweb.cgi renamed from gitweb/gitweb.cgi +12 -2
@@ -40,6 +40,8 @@
 #my $projects_list = $projectroot;
 my $projects_list = "index/index.aux";
 
+my $snapshots_url = "http://git.xmms.se/snapshot.cgi";
+
 # input validation and dispatch
 my $action = $cgi->param('a');
 if (defined $action) {
@@ -845,6 +847,7 @@
 		      $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=summary"}, "summary") .
 		      " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=shortlog"}, "shortlog") .
 		      " | " . $cgi->a({-href => "$my_uri?p=$pr->{'path'};a=log"}, "log") .
+		      " | " . $cgi->a({-href => "$snapshots_url?tree=$pr->{'path'}&commit=HEAD"}, "latest snapshot") .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
@@ -984,6 +987,7 @@
 			      "<td class=\"link\">" .
 			      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
 			      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
+			      " | " . $cgi->a({-href => "$snapshots_url?tree=$project&commit=$commit"}, "snapshot") .
 			      "</td>\n" .
 			      "</tr>";
 		} else {
@@ -1033,7 +1037,8 @@
 				print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
 				if ($tag{'reftype'} eq "commit") {
 				      print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
-				            " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
+				            " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log") .
+				            " | " . $cgi->a({-href => "$snapshots_url?tree=$project&commit=$tag{'refid'}"}, "snapshot");
 				}
 				print "</td>\n" .
 				      "</tr>";
@@ -1172,7 +1177,8 @@
 			print $cgi->a({-href => "$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"}, $tag{'reftype'});
 			if ($tag{'reftype'} eq "commit") {
 			      print " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$tag{'name'}"}, "shortlog") .
-			            " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log");
+			            " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;h=$tag{'refid'}"}, "log") .
+			            " | " . $cgi->a({-href => "$snapshots_url?tree=$project&commit=$tag{'refid'}"}, "snapshot");
 			}
 			print "</td>\n" .
 			      "</tr>";
@@ -1545,6 +1551,7 @@
 		      "<div class=\"log_link\">\n" .
 		      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
 		      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
+		      " | " . $cgi->a({-href => "$snapshots_url?tree=$project&commit=$commit"}, "snapshot") .
 		      "<br/>\n" .
 		      "</div>\n" .
 		      "<i>" . escapeHTML($co{'author_name'}) .  " [$ad{'rfc2822'}]</i><br/>\n" .
@@ -1646,6 +1653,8 @@
 		      "</td>" .
 		      "</tr>\n";
 	}
+	print "<tr><td>snapshot</td>".
+	      "<td><a href=\"$snapshots_url?tree=$project&commit=$hash\">$hash</a></td></tr>";
 	print "</table>". 
 	      "</div>\n";
 	print "<div class=\"page_body\">\n";
@@ -2234,6 +2243,7 @@
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") .
 		      " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") .
+		      " | " . $cgi->a({-href => "$snapshots_url?tree=$project&commit=$commit"}, "snapshot") .
 		      "</td>\n" .
 		      "</tr>";
 	}
#1 lore raw
Quoted 8 lines · Sham Chukoury

G'day.

I figured you folks might be interested in a number of modifications the XMMS2 team have made to gitweb. All the changes can be seen at
http://git.xmms.se

1) Navbar refactoring (gitweb-xmms2navbar.diff)
3) Snapshot integration (gitweb-xmms2snapshots.diff & snapshot.cgi)

I've sent similar patches to the git mailing list almost two months ago, but Kay didn't take them.
Maybe you could compare with my version

http://www.liacs.nl/~sverdool/gitweb.cgi?p=gitweb.git;a=summary

(I'll be mostly offline for the next couple of days.)

skimo