Question

I'm looking to add the name of the person who made the last commit to each project on the GitWeb project list, so instead of

14 min ago

it says something like

14 min ago (Someone's Name)

I've had a look through gitweb.cgi and found the point where the string is written (line 5488 in mine), but I don't really know how to proceed.

Has anyone already done this? Or can anyone offer a quick solution?

Was it helpful?

Solution

Thanks to simbabque for pointing me to git_get_last_activity. My solution (possibly sub-optimal, let me know if it is):

Change git_get_last_activity to

sub git_get_last_activity {
my ($path) = @_;
my $fd;

$git_dir = "$projectroot/$path";
open($fd, "-|", git_cmd(), 'for-each-ref',
     '--format=%(committer)',
     '--sort=-committerdate',
     '--count=1',
     'refs/heads') or return;
my $most_recent = <$fd>;
close $fd or return;
if (defined $most_recent &&
    $most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
  my $bracket_position = rindex($most_recent, "<");
  my $committer_name = substr($most_recent, 0, $bracket_position - 1);
    my $timestamp = $1;
    my $age = time - $timestamp;
    return ($age, age_string($age), $committer_name);
}
return (undef, undef, undef);
}

Then search for where that is called later (should only be once) and change

($pr->{'age'}, $pr->{'age_string'}) = @activity;

to be

($pr->{'age'}, $pr->{'age_string'}, $pr->{'committer'}) = @activity;

Then go to git_project_list_rows and change

(defined $pr->{'age_string'} ? $pr->{'age_string'} : "No commits") . "</td>\n" .

to

(defined $pr->{'age_string'} ? $pr->{'age_string'} . ' (' . $pr->{'committer'} . ')' : "No commits") . "</td>\n" .
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top