gitweb: Add support for per project git URLs

It is now possible for project to have individual clone/fetch URLs.
They are provided in new file 'cloneurl' added below project's
$GIT_DIR directory.

If there is no cloneurl file, concatenation of git base URLs with
project name is used.

This is merge of Jakub Narebski and David Rientjes
  gitweb: Show project's git URL on summary page
with Aneesh Kumar
  gitweb: Add support for cloneurl.
  gitweb: Support multiple clone urls
patches.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Jakub Narebski 2006-08-16 14:50:34 +02:00 committed by Junio C Hamano
parent 1c2a4f5add
commit e79ca7cc25

View File

@ -533,6 +533,16 @@ sub git_get_project_description {
return $descr; return $descr;
} }
sub git_get_project_url_list {
my $path = shift;
open my $fd, "$projectroot/$path/cloneurl" or return undef;
my @git_project_url_list = map { chomp; $_ } <$fd>;
close $fd;
return wantarray ? @git_project_url_list : \@git_project_url_list;
}
sub git_get_projects_list { sub git_get_projects_list {
my @list; my @list;
@ -1697,10 +1707,14 @@ sub git_summary {
"<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" . "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
"<tr><td>owner</td><td>$owner</td></tr>\n" . "<tr><td>owner</td><td>$owner</td></tr>\n" .
"<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n"; "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
# use per project git URL list in $projectroot/$project/cloneurl
# or make project git URL from git base URL and project name
my $url_tag = "URL"; my $url_tag = "URL";
foreach my $git_base_url (@git_base_url_list) { my @url_list = git_get_project_url_list($project);
next unless $git_base_url; @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
print "<tr><td>$url_tag</td><td>$git_base_url/$project</td></tr>\n"; foreach my $git_url (@url_list) {
next unless $git_url;
print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
$url_tag = ""; $url_tag = "";
} }
print "</table>\n"; print "</table>\n";