From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1373B1F47C for ; Thu, 5 Jan 2023 09:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1672912721; bh=ZOD4eDzeGYhzwNor+sHM8DaZ4SwqK/970dPemY5tqbM=; h=Date:From:To:Subject:References:In-Reply-To:From; b=yi84lAq+tLNSPyVjxqu5wUBSSAV/Lyrq+9xyL1ckK5H2JfmuIJO9R4TueRxt+qKJh d/QPknxhLdLP8SaPxrzlkio56MJA9wHsilQN4hHmS1fm76b0ju0sA6DYr6p0+5rcDj SrZyulalNwfbVqh2kECeDmK/IvSmDDljc9yPX7eo= Date: Thu, 5 Jan 2023 09:58:41 +0000 From: Eric Wong To: meta@public-inbox.org Subject: Re: [PATCH 2/3] git: pub_urls shows base_url default Message-ID: <20230105095841.M468667@dcvr> References: <20230104103405.2432349-1-e@80x24.org> <20230104103405.2432349-3-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230104103405.2432349-3-e@80x24.org> List-Id: Eric Wong wrote: > Since we have native coderepo viewing support without cgit, > configuring coderepo.$FOO.cgitUrl shouldn't be necessary anymore > and we can infer the public name based on the project nickname > (or whatever's in the generated project.list) > --- > lib/PublicInbox/Git.pm | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm > index 68f72052..f6abe185 100644 > --- a/lib/PublicInbox/Git.pm > +++ b/lib/PublicInbox/Git.pm > @@ -480,9 +480,10 @@ sub isrch {} # TODO > sub pub_urls { > my ($self, $env) = @_; > if (my $urls = $self->{cgit_url}) { > - return map { host_prefix_url($env, $_) } @$urls; > + map { host_prefix_url($env, $_) } @$urls; > + } else { > + (base_url($self, $env)); > } > - (local_nick($self) // '???'); > } > > sub cat_async_begin { Erm, $git->{nick} isn't guaranteed to exist, actually. Perhaps it should and the code shouldn't have to guard against it, but there's cases where we need this and I'll squash it in: diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index dff5813f..96627daa 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -485,10 +485,11 @@ sub host_prefix_url ($$) { sub base_url { # for coderepos, PSGI-only my ($self, $env) = @_; # env - PSGI env + my $nick = $self->{nick} // return undef; my $url = host_prefix_url($env, ''); # for mount in Plack::Builder $url .= '/' if substr($url, -1, 1) ne '/'; - $url . $self->{nick} . '/'; + $url . $nick . '/'; } sub isrch {} # TODO @@ -498,7 +499,7 @@ sub pub_urls { if (my $urls = $self->{cgit_url}) { map { host_prefix_url($env, $_) } @$urls; } else { - (base_url($self, $env)); + (base_url($self, $env) // '???'); } }