Thread (8 messages) 8 messages, 3 authors, 2016-06-15

Re: [PATCH] gitweb: Show project's git URL on summary page

From: David Rientjes <rientjes@google.com>
Date: 2016-06-15 22:42:37
Subsystem: the rest · Maintainer: Linus Torvalds

On Tue, 15 Aug 2006, Jakub Narebski wrote:
quoted hunk ↗ jump to hunk
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ab28caa..6dcf6a2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -51,6 +51,10 @@ our $logo = "++GITWEB_LOGO++";
 # source of projects list
 our $projects_list = "++GITWEB_LIST++";
 
+# list of git base URLs used for URL to where fetch project from,
+# i.e. full URL is "$git_base_url/$project"
+our @git_base_url_list = ("++GIT_BASE_URL++");
+
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
 our $default_text_plain_charset  = undef;
@@ -1665,8 +1669,18 @@ sub git_summary {
 	print "<table cellspacing=\"0\">\n" .
 	      "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
 	      "<tr><td>owner</td><td>$owner</td></tr>\n" .
-	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
-	      "</table>\n";
+	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
+	my $is_first_url = 1;
+	foreach my $git_base_url (@git_base_url_list) {
+		next unless $git_base_url; # skip empty/zerolength URLs
+		print "<tr><td>";
+		if ($is_first_url) {
+			print "URL";
+			$is_first_url = 0;
+		}
+		print "</td><td>$git_base_url/$project</td></tr>\n";
+	}
+	print "</table>\n";
 
 	open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash($project)
 		or die_error(undef, "Open git-rev-list failed");
Isn't it faster to do this (over 1.4.2):
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b5b89de..82b246d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -53,6 +53,7 @@ our $logo = "++GITWEB_LOGO++";
 
 # source of projects list
 our $projects_list = "++GITWEB_LIST++";
+our @git_base_url_list = ("++GIT_BASE_URL++");
 
 # default blob_plain mimetype and default charset for text/plain blob
 our $default_blob_plain_mimetype = 'text/plain';
@@ -1668,8 +1669,14 @@ sub git_summary {
 	print "<table cellspacing=\"0\">\n" .
 	      "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
 	      "<tr><td>owner</td><td>$owner</td></tr>\n" .
-	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
-	      "</table>\n";
+	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
+	my $url_tag = "URL";
+	foreach my $git_base_url (@git_base_url_list) {
+		next unless $git_base_url;
+		print "<tr><td>$url_tag</td><td>$git_base_url/$project</td></tr>\n";
+		$url_tag = "";
+	}
+	print "</table>\n";
 
 	open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash($project)
 		or die_error(undef, "Open git-rev-list failed");
--
All the series of prints in this script could also probably more elegantly be 
written in the form:

print <<"(END HTML)";
	<table cellspacing="0">
		...
	</table>
	<tr><td>last change</td><td>$cd{'rfc2822'}</td><tr>
	...
(END HTML)

and then all the escape characters around quotes aren't needed.

		David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help