From: Junio C Hamano <junkio@cox.net>
To: Pierre Marc Dumuid <pierre.dumuid@adelaide.edu.au>
Cc: git@vger.kernel.org
Subject: Re: gitweb.cgi feature request: project list "last change" column to display last change of all heads.
Date: Sun, 15 Oct 2006 03:28:07 -0700 [thread overview]
Message-ID: <7vfydpzxe0.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <4531FC77.6010004@adelaide.edu.au> (Pierre Marc Dumuid's message of "Sun, 15 Oct 2006 18:46:39 +0930")
Pierre Marc Dumuid <pierre.dumuid@adelaide.edu.au> writes:
> The annoying thing is that in our mirrored personal repositories, we
> switch from head to head and push new features in different head, and
> then wait for the other developers to review. At the moment, the
> getweb.cgi script only shows the "Last Change" for the current branch,
> and not all branches, (i.e. it's currently showing "13 days ago" for
> cinelerra-pmdumuid, whilst if you click the summary, you'll see I
> actually extended one of the branches only "24 hours ago".
It is fairly expensive to do without recent core-side support,
but if the site runs version of git from the "next" branch,
you should be able to do something like this.
I'll queue this to "next".
-- >8 --
gitweb: use for-each-ref to show the latest activity across branches
The project list page shows last change from the HEAD branch but
often people would want to view activity on any branch.
Unfortunately that is fairly expensive without the core-side
support. for-each-ref was invented exactly for that.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e4ebce6..a78c8db 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1009,6 +1009,24 @@ sub parse_tag {
return %tag
}
+sub git_get_last_activity {
+ my ($path) = @_;
+ my $fd;
+
+ $git_dir = "$projectroot/$path";
+ open($fd, "-|", git_cmd(), 'for-each-ref',
+ '--format=%(refname) %(committer)',
+ '--sort=-committerdate',
+ 'refs/heads') or return;
+ my $most_recent = <$fd>;
+ close $fd or return;
+ if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
+ my $timestamp = $1;
+ my $age = time - $timestamp;
+ return ($age, age_string($age));
+ }
+}
+
sub parse_commit {
my $commit_id = shift;
my $commit_text = shift;
@@ -2258,16 +2276,11 @@ sub git_project_list {
die_error(undef, "No projects found");
}
foreach my $pr (@list) {
- my $head = git_get_head_hash($pr->{'path'});
- if (!defined $head) {
- next;
- }
- $git_dir = "$projectroot/$pr->{'path'}";
- my %co = parse_commit($head);
- if (!%co) {
+ my (@aa) = git_get_last_activity($pr->{'path'});
+ unless (@aa) {
next;
}
- $pr->{'commit'} = \%co;
+ ($pr->{'age'}, $pr->{'age_string'}) = @aa;
if (!defined $pr->{'descr'}) {
my $descr = git_get_project_description($pr->{'path'}) || "";
$pr->{'descr'} = chop_str($descr, 25, 5);
@@ -2317,7 +2330,7 @@ sub git_project_list {
"</th>\n";
}
if ($order eq "age") {
- @projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
+ @projects = sort {$a->{'age'} <=> $b->{'age'}} @projects;
print "<th>Last Change</th>\n";
} else {
print "<th>" .
@@ -2339,8 +2352,8 @@ sub git_project_list {
-class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
"<td>" . esc_html($pr->{'descr'}) . "</td>\n" .
"<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
- print "<td class=\"". age_class($pr->{'commit'}{'age'}) . "\">" .
- $pr->{'commit'}{'age_string'} . "</td>\n" .
+ print "<td class=\"". age_class($pr->{'age'}) . "\">" .
+ $pr->{'age_string'} . "</td>\n" .
"<td class=\"link\">" .
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary") . " | " .
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " .
next prev parent reply other threads:[~2006-10-15 10:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-15 9:16 gitweb.cgi feature request: project list "last change" column to display last change of all heads Pierre Marc Dumuid
2006-10-15 10:28 ` Junio C Hamano [this message]
2006-10-15 12:17 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vfydpzxe0.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=pierre.dumuid@adelaide.edu.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.