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

From: Jakub Narebski <jnareb@gmail.com>
Date: 2006-08-16 04:03:05
Add support for showing multiple clone/fetch git URLs for project on
a summary page. URL for project is created from base URL and project
name.

For example for XMMS2 project (xmms.se) the git base URL would be
git://git.xmms.se/xmms2.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This probably could be combined with Aneesh Kumar patches 
  "[PATCH] gitweb: Add support for cloneurl."
  "[PATCH] gitweb: Support multiple clone urls"
which reads from clone/fetch URLs from $GIT_DIR/cloneurl file,
i.e. from $projectroot/$project/cloneurl file.  Default would be to
use base URL from @git_base_url_list, and if there is cloneurl file
for a project, use it instead.

I'm not so sure of benefits of yet another way to provide
clone/fetch URL, namely Yasushi SHOJI
  "[PATCH] gitweb: configurable home link string"

This patch is port (with improvements) of Sham Chukoury patch
  "Show project tree git url on summary page" (8e327dfbd)
for gitweb-xmms2. Should I add below line to commit message?

Signed-off-by: Sham Chukoury <eleusis@xmms.org>


 Makefile           |    2 ++
 gitweb/gitweb.perl |   18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a538710..ae77d99 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,7 @@ # default configuration for gitweb
 GITWEB_CONFIG = gitweb_config.perl
 GITWEB_SITENAME =
 GITWEB_PROJECTROOT = /pub/git
+GITWEB_BASE_URL =
 GITWEB_LIST =
 GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
@@ -619,6 +620,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 	    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 	    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
+	    -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 	    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 	    -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 	    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
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");
-- 
1.4.1.1

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed Aug 16 04:03:03 2006

This archive was generated by hypermail 2.1.8 : 2006-08-16 04:03:37 EST