]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwCoderepo.pm
No ext_urls
[public-inbox.git] / lib / PublicInbox / WwwCoderepo.pm
index d28b1a03d9dc196ba93115f80f6ee3271bbf5134..52ab6e4800b3930af46991f6e5059ecfcb6bc4b9 100644 (file)
@@ -123,17 +123,16 @@ sub _refs_tags_link {
 sub summary_finish {
        my ($ctx) = @_;
        my $wcb = delete($ctx->{env}->{'qspawn.wcb'}) or return; # already done
-       my @x = split(/\n\n/sm, delete($ctx->{-each_refs}));
+       my @x = split(/\n\n/sm, delete($ctx->{-each_refs}), 3);
        PublicInbox::WwwStream::html_init($ctx);
        my $zfh = $ctx->zfh;
 
        # git log
-       my @r = split(/\n/s, pop(@x) // '');
-       my $last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_log};
+       my @r = split(/\n/s, pop(@x));
+       my $last = scalar(@r) > $ctx->{wcr}->{summary_log} ? pop(@r) : undef;
        my $tip_html = '';
-       if (defined(my $tip = $ctx->{qp}->{h})) {
-               $tip_html .= ' '.ascii_html($tip).' --';
-       }
+       my $tip = $ctx->{qp}->{h};
+       $tip_html .= ' '.ascii_html($tip).' --' if defined $tip;
        print $zfh <<EOM;
 <pre><a id=log>\$</a> git log --pretty=format:'%h %s (%cs)%d'$tip_html
 EOM
@@ -146,7 +145,7 @@ EOM
                        " (", $cs, ")\n";
                print $zfh "\t(", ascii_html($d), ")\n" if $d;
        }
-       print $zfh "# no commits, yet\n" if !@r;
+       print $zfh '# no commits in `', ($tip//'HEAD'),"', yet\n\n" if !@r;
        print $zfh "...\n" if $last;
 
        # README
@@ -165,14 +164,14 @@ EOM
        # refs/heads
        print $zfh '<a id=heads>', $HEADS_CMD , '</a>';
        @r = split(/^/sm, shift(@x) // '');
-       $last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_branches};
+       $last = scalar(@r) > $ctx->{wcr}->{summary_branches} ? pop(@r) : undef;
        chomp(@r);
        for (@r) { print $zfh _refs_heads_link($_, './') }
        print $zfh $NO_HEADS if !@r;
        print $zfh qq(<a href="refs/heads/">...</a>\n) if $last;
        print $zfh "\n<a id=tags>", $TAGS_CMD, '</a>';
        @r = split(/^/sm, shift(@x) // '');
-       $last = pop(@r) if scalar(@r) > $ctx->{wcr}->{summary_tags};
+       $last = scalar(@r) > $ctx->{wcr}->{summary_tags} ? pop(@r) : undef;
        my ($snap_pfx, @snap_fmt) = _snapshot_link_prep($ctx);
        chomp @r;
        for (@r) { print $zfh _refs_tags_link($_, './', $snap_pfx, @snap_fmt) }
@@ -216,9 +215,10 @@ sub summary {
                "$EACH_REF --count=$nb refs/heads; echo && " .
                "$EACH_REF --count=$nt refs/tags; echo && " .
                qq(git log -$nl --pretty=format:'%d %H %h %cs %s' "\$@" --));
-       push @cmd, '--', $tip if defined($tip);
+       push @cmd, 'git', $tip if defined($tip);
        my $qsp = PublicInbox::Qspawn->new(\@cmd,
-               { GIT_DIR => $ctx->{git}->{git_dir} });
+               { GIT_DIR => $ctx->{git}->{git_dir} },
+               { quiet => 1, 2 => $self->{log_fh} });
        $qsp->{qsp_err} = \($ctx->{-qsp_err} = '');
        $tip //= 'HEAD';
        my @try = ("$tip:README", "$tip:README.md"); # TODO: configurable
@@ -308,6 +308,7 @@ sub srv { # endpoint called by PublicInbox::WWW
                PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404);
        } elsif ($path_info =~ m!\A/(.+?)/atom/(.*)\z! and
                        ($ctx->{git} = $cr->{$1})) {
+               $ctx->{lh} = $self->{log_fh};
                PublicInbox::RepoAtom::srv_atom($ctx, $2) // r(404);
        } elsif ($path_info =~ m!\A/(.+?)/tags\.atom\z! and
                        ($ctx->{git} = $cr->{$1})) {