]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www_coderepo: quiet 404s on Atom feeds for dead branches
authorEric Wong <e@80x24.org>
Tue, 14 Feb 2023 13:17:38 +0000 (13:17 +0000)
committerEric Wong <e@80x24.org>
Wed, 15 Feb 2023 04:31:22 +0000 (04:31 +0000)
No need to clutter up logs when a request hits a dead branch.

lib/PublicInbox/RepoAtom.pm
lib/PublicInbox/WwwCoderepo.pm
t/solver_git.t

index 44883ab468e81c15636aa215731a1a31db5ebad4..c89d455141f0ea716f10973b60545bde35395e20 100644 (file)
@@ -120,7 +120,8 @@ sub srv_atom {
        # else: let git decide based on HEAD if $tip isn't defined
        push @cmd, '--';
        push @cmd, $path if $path ne '';
-       my $qsp = PublicInbox::Qspawn->new(\@cmd);
+       my $qsp = PublicInbox::Qspawn->new(\@cmd, undef,
+                                       { quiet => 1, 2 => $ctx->{lh} });
        $qsp->psgi_return($ctx->{env}, undef, \&atom_ok, $ctx);
 }
 
index 7a2cb80bd33dc3d679f4c666a297a4aa27cdd200..8a490b6cb66c26c875c7eb26c09cb58ffbaf4b6a 100644 (file)
@@ -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})) {
index 0090bc06d6165c9fd44ca57745c26b3413cc33e0..79672398f88cfe9fcdbad92629f68136eda7d2cc 100644 (file)
@@ -379,7 +379,10 @@ EOF
                        ok($t->{feed}->{entry}, 'got entry');
 
                        $res = $cb->(GET('/public-inbox/atom/README.md'));
-                       is($res->code, 404, '404 on non-existent file Atom feed');
+                       is($res->code, 404, '404 on missing file Atom feed');
+
+                       $res = $cb->(GET('/public-inbox/atom/?h=gone'));
+                       is($res->code, 404, '404 on missing Atom feed branch');
                }
 
                $res = $cb->(GET('/public-inbox/tree/'));