gitweb: Show project's git URL on summary page
PATCH 1/1 gitweb: Show project's git URL on summary page
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 begit://git.xmms.se/xmms2.
---
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?
Makefile | 2 ++ gitweb/gitweb.perl | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
Makefile +2 -0
@@ -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' \
gitweb/gitweb.perl +16 -2
@@ -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");
Signature · 1 line
1.4.1.1
PATCH 1/1 gitweb: Show project's git URL on summary page
Quoted 1 line
From
31e4de9f22a3b17d4ad0ac800132e4e1a0a15006Mon Sep 17 00:00:00 2001
From: David Rientjes <[email protected]>
Date: Tue, 15 Aug 2006 11:43:04 -0700
Subject: [PATCH] gitweb: Show project's git URL on summary page
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 begit://git.xmms.se/xmms2.
With corrections from David Rientjes <[email protected]>
--- Makefile | 2 ++ gitweb/gitweb.perl | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
Makefile +2 -0
@@ -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' \
gitweb/gitweb.perl +12 -2
@@ -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 = ("++GITWEB_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,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");
Signature · 1 line
1.4.1.1
PATCH 2/2 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.
---
Based on previous patch.
gitweb/gitweb.perl | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +17 -3
@@ -533,6 +533,16 @@ sub git_get_project_description { 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 { my @list;
@@ -1697,10 +1707,14 @@ sub git_summary { "<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"; + # 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"; - 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"; + my @url_list = git_get_project_url_list($project); + @url_list = map { "$_/$project" } @git_base_url_list unless @url_list; + foreach my $git_url (@url_list) { + next unless $git_url; + print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n"; $url_tag = ""; } print "</table>\n";
Signature · 1 line
1.4.1.1
Re: [PATCH 2/2] gitweb: Add support for per project git URLs
Quoted 14 lines · Jakub Narebski
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.
Quoted 2 lines
Signed-off-by Jakub Narebski <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>
I'll take this for now, but we might want to consider moving 'description' and 'cloneurl' information to the config file to prevent cluttering.
gitweb.description
gitweb.giturl
The URL is not for cloning only, but also for fetch/pull, right?
Re: [PATCH 2/2] gitweb: Add support for per project git URLs
Quoted 19 lines · Junio C Hamano
Quoted 14 lines · Jakub Narebski
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.Quoted 2 lines
Signed-off-by Jakub Narebski <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>
Quoted 8 lines
I'll take this for now, but we might want to consider moving 'description' and 'cloneurl' information to the config file to prevent cluttering.
gitweb.description
gitweb.giturlThe URL is not for cloning only, but also for fetch/pull, right?
As of now reading text file is faster than invoking git-repo-config... although reimplementing _reading_ part of git-repo-config in Perl should be easy...
cloneurl name is leftover from Aneesh Kumar patch.
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Quoted 9 lines · Jakub Narebski
From
31e4de9f22a3b17d4ad0ac800132e4e1a0a15006Mon Sep 17 00:00:00 2001
From: David Rientjes <[email protected]>
Date: Tue, 15 Aug 2006 11:43:04 -0700
Subject: [PATCH] gitweb: Show project's git URL on summary pageAdd 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.
Quoted 6 lines
For example for XMMS2 project (xmms.se) the git base URL would be
git://git.xmms.se/xmms2.With corrections from David Rientjes <[email protected]>
Signed-off-by Jakub Narebski <[email protected]>
Quoted 5 lines · Jakub Narebski
From
31e4de9f22a3b17d4ad0ac800132e4e1a0a15006Mon Sep 17 00:00:00 2001
From: David Rientjes <[email protected]>
Date: Tue, 15 Aug 2006 11:43:04 -0700
Subject: [PATCH] gitweb: Show project's git URL on summary page
Quoted 9 lines
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.With corrections from David Rientjes <[email protected]>
this can give wrong value is some case with index.aux as projects_list. I have a setup where project details are displayed via gitweb but not reachable via http:// url and some reachable via http:// url.
For the first one only ssh:// based clone mechanism will work and for the other both will work. How do we handle that
-aneesh
Quoted 6 lines · Aneesh Kumar K.V
this can give wrong value is some case with index.aux as
projects_list. I have a setup where project details are displayed via gitweb but not reachable via http:// url and some reachable via http:// url.For the first one only ssh:// based clone mechanism will work and for the other both will work. How do we handle that
See my "[PATCH 2/2] gitweb: Add support for per project git URLs" in this thread.
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Quoted 27 lines · Jakub Narebski
gitweb/gitweb.perl +9
-2@@ -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>";
gitweb/gitweb.perl sub git_summary { · line 1686
Quoted 10 lines
gitweb/gitweb.perl +7
-0+ 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):
gitweb/gitweb.perl +9 -2
@@ -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
Jakub Narebski
Acked-byQuoted 14 lines · David Rientjes
Review
Quoted 10 lines · Jakub Narebski
(quoted diff) +10
-0+ 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"; + }Isn't it faster to do this (over 1.4.2):
gitweb/gitweb.perl sub git_summary { · line 1678
Quoted 6 lines
gitweb/gitweb.perl +6
-0+ 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 = ""; + }
Yes, it is undobtedly better.
Signature · 1 line
Jakub Narebski