unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] www_coderepo: quiet 404s on Atom feeds for dead branches
Date: Tue, 14 Feb 2023 13:17:38 +0000	[thread overview]
Message-ID: <20230214131739.2978030-2-e@80x24.org> (raw)
In-Reply-To: <20230214131739.2978030-1-e@80x24.org>

No need to clutter up logs when a request hits a dead branch.
---
 lib/PublicInbox/RepoAtom.pm    | 3 ++-
 lib/PublicInbox/WwwCoderepo.pm | 1 +
 t/solver_git.t                 | 5 ++++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/RepoAtom.pm b/lib/PublicInbox/RepoAtom.pm
index 44883ab4..c89d4551 100644
--- a/lib/PublicInbox/RepoAtom.pm
+++ b/lib/PublicInbox/RepoAtom.pm
@@ -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);
 }
 
diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm
index 7a2cb80b..8a490b6c 100644
--- a/lib/PublicInbox/WwwCoderepo.pm
+++ b/lib/PublicInbox/WwwCoderepo.pm
@@ -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})) {
diff --git a/t/solver_git.t b/t/solver_git.t
index 0090bc06..79672398 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -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/'));

  reply	other threads:[~2023-02-14 13:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 13:17 [PATCH 0/2] www_coderepo: graceful dead branch handling Eric Wong
2023-02-14 13:17 ` Eric Wong [this message]
2023-02-14 13:17 ` [PATCH 2/2] www_coderepo: handle unborn/dead branches in summary Eric Wong
2023-02-15  4:49   ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230214131739.2978030-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).