Eric Wong <[email protected]> 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) // '???');
        }
 }
 

Reply via email to