From 703ac7102fb66f748f9a636f57852909b4425496 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:03:14 +0200 Subject: [PATCH] v021 --- gitweb.pl | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd5fbdc2a8..6d604d732e 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -157,6 +157,47 @@ sub git_head { return $head; } +sub git_commit { + my $commit = shift; + my %co; + my @parents; + + open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^tree (.*)$/) { + $co{'tree'} = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + $co{'committer'} = $1; + $co{'committer_time'} = $2; + $co{'committer_timezone'} = $3; + } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + $co{'$author'} = $1; + $co{'$author_time'} = $2; + $co{'$author_timezone'} = $3; + } + } + my $shortlog = <$fd>; + chomp($shortlog); + $co{'shortlog'} = escapeHTML($shortlog); + my $comment = $shortlog . "
"; + while (my $line = <$fd>) { + chomp($line); + if ($line =~ m/signed-off-by:/i) { + $comment .= '
' . escapeHTML($line) . "
\n"; + } else { + $comment .= escapeHTML($line) . "
\n"; + } + } + $co{'comment'} = $comment; + close $fd; + + return %co; +} + sub git_diff { my $old_name = shift || "/dev/null"; my $new_name = shift || "/dev/null"; @@ -408,11 +449,10 @@ if ($action eq "blob") { print ""; print "\n"; } elsif ($action eq "rss") { - if ($i < 12) { - print "\n\t$age_string: $shortlog\n"; - print "\t " . $cgi->url() . "/$project/commit/$commit\n"; - print "\n"; - } + last if ($i >= 12); + print "\n\t$age_string: $shortlog\n"; + print "\t " . $cgi->url() . "/$project/commit/$commit\n"; + print "\n"; } } if ($action eq "log") {