* Git backend improvements, including bug fixes and better robustness.

master
joey 2006-11-26 20:05:57 +00:00
parent b20d4f6681
commit c8a59c1c10
2 changed files with 29 additions and 23 deletions

View File

@ -153,14 +153,15 @@ sub _parse_diff_tree (@) { #{{{
my ($dt_ref) = @_; my ($dt_ref) = @_;
# End of stream? # End of stream?
return if !defined @{ $dt_ref } || !length @{ $dt_ref }[0]; return if !defined @{ $dt_ref } ||
!defined @{ $dt_ref }[0] || !length @{ $dt_ref }[0];
my %ci; my %ci;
# Header line. # Header line.
HEADER: while (my $line = shift @{ $dt_ref }) { HEADER: while (my $line = shift @{ $dt_ref }) {
return if $line !~ m/^(.+) ($sha1_pattern)/; return if $line !~ m/^(.+) ($sha1_pattern)/;
my $sha1 = $1; my $sha1 = $2;
$ci{'sha1'} = $sha1; $ci{'sha1'} = $sha1;
last HEADER; last HEADER;
} }
@ -195,10 +196,10 @@ sub _parse_diff_tree (@) { #{{{
} }
} }
error("No 'tree' or 'parents' seen in diff-tree output") debug("No 'tree' or 'parents' seen in diff-tree output")
if !defined $ci{'tree'} || !defined $ci{'parents'}; if !defined $ci{'tree'} || !defined $ci{'parents'};
$ci{'parent'} = @{ $ci{'parents'} }[0]; $ci{'parent'} = @{ $ci{'parents'} }[0] if defined $ci{'parents'};
# Commit message. # Commit message.
COMMENT: while (my $line = shift @{ $dt_ref }) { COMMENT: while (my $line = shift @{ $dt_ref }) {
@ -239,14 +240,14 @@ sub _parse_diff_tree (@) { #{{{
last FILE; last FILE;
} }
warn "No detail in diff-tree output" if !defined $ci{'details'}; debug("No detail in diff-tree output") if !defined $ci{'details'};
return \%ci; return \%ci;
} #}}} } #}}}
sub git_commit_info (;$$) { #{{{ sub git_commit_info ($;$) { #{{{
# Return an array of commit info hashes of num commits (default: 1) # Return an array of commit info hashes of num commits (default: 1)
# starting from the given sha1sum (default: HEAD). # starting from the given sha1sum.
my ($sha1, $num) = @_; my ($sha1, $num) = @_;
@ -254,7 +255,7 @@ sub git_commit_info (;$$) { #{{{
my @raw_lines = my @raw_lines =
run_or_die(qq{git-rev-list --max-count=$num $sha1 | run_or_die(qq{git-rev-list --max-count=$num $sha1 |
git-diff-tree --stdin --pretty=raw -M -r}); git-diff-tree --stdin --pretty=raw --always -M -m -r});
my @ci; my @ci;
while (my $parsed = _parse_diff_tree(\@raw_lines)) { while (my $parsed = _parse_diff_tree(\@raw_lines)) {
@ -352,17 +353,19 @@ sub rcs_recentchanges ($) { #{{{
eval q{use Date::Parse}; eval q{use Date::Parse};
error($@) if $@; error($@) if $@;
my ($sha1, $type, $when, $diffurl, $user, @pages, @message, @rets); my @rets;
INFO: foreach my $ci (git_commit_info('HEAD', $num)) { INFO: foreach my $ci (git_commit_info('HEAD', $num)) {
my $title = @{ $ci->{'comment'} }[0]; my $title = @{ $ci->{'comment'} }[0];
# Skip redundant commits. # Skip redundant commits.
next INFO if ($title eq $dummy_commit_msg); next INFO if ($title eq $dummy_commit_msg);
$sha1 = $ci->{'sha1'}; my ($sha1, $when) = (
$type = "web"; $ci->{'sha1'},
$when = time - $ci->{'author_epoch'}; time - $ci->{'author_epoch'}
);
my (@pages, @messages);
DETAIL: foreach my $detail (@{ $ci->{'details'} }) { DETAIL: foreach my $detail (@{ $ci->{'details'} }) {
my $diffurl = $config{'diffurl'}; my $diffurl = $config{'diffurl'};
my $file = $detail->{'file'}; my $file = $detail->{'file'};
@ -377,13 +380,14 @@ sub rcs_recentchanges ($) { #{{{
diffurl => $diffurl, diffurl => $diffurl,
}; };
} }
push @messages, { line => $title };
push @message, { line => $title }; my ($user, $type) = (q{}, "web");
if (defined $message[0] && if (defined $messages[0] &&
$message[0]->{line} =~ m/$config{web_commit_regexp}/) { $messages[0]->{line} =~ m/$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3"; $user=defined $2 ? "$2" : "$3";
$message[0]->{line}=$4; $messages[0]->{line}=$4;
} else { } else {
$type ="git"; $type ="git";
$user = $ci->{'author_username'}; $user = $ci->{'author_username'};
@ -394,12 +398,11 @@ sub rcs_recentchanges ($) { #{{{
user => $user, user => $user,
committype => $type, committype => $type,
when => $when, when => $when,
message => [@message], message => [@messages],
pages => [@pages], pages => [@pages],
} if @pages; };
$sha1 = $type = $when = $diffurl = $user = undef; last INFO if @rets >= $num;
@pages = @message = ();
} }
return @rets; return @rets;

9
debian/changelog vendored
View File

@ -10,6 +10,8 @@ ikiwiki (1.34) UNRELEASED; urgency=low
* Make the openid plugin support the callbacks from myopenid.com via its * Make the openid plugin support the callbacks from myopenid.com via its
affiliate program. affiliate program.
* Add toggle plugin. * Add toggle plugin.
* Add a poll plugin.
* Add quick mode for archive page generation.
* Introduce the goodstuff bundle. This is a kind of plugin, that just enables * Introduce the goodstuff bundle. This is a kind of plugin, that just enables
many other plugins. It's an easy way to boost ikiwiki from its default, many other plugins. It's an easy way to boost ikiwiki from its default,
basic wiki, to a full-featured wiki, without manually picking the right basic wiki, to a full-featured wiki, without manually picking the right
@ -44,9 +46,10 @@ ikiwiki (1.34) UNRELEASED; urgency=low
and their IP address, and needs to construct its own commit message and their IP address, and needs to construct its own commit message
containing them, or do something more appropriate for the given RCS. containing them, or do something more appropriate for the given RCS.
* Add softwaresite example. * Add softwaresite example.
* Add a poll plugin. * Mercurial backend improvements, including --get-ctime support. (Emanuele
* Add quick mode for archive page generation. Aina)
* Mercurial backend improvements, including --get-ctime support. * Git backend improvements, including bug fixes and better robustness.
(Recai Oktaş)
-- Joey Hess <joeyh@debian.org> Sun, 26 Nov 2006 15:01:14 -0500 -- Joey Hess <joeyh@debian.org> Sun, 26 Nov 2006 15:01:14 -0500