]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git: pub_urls shows base_url default
authorEric Wong <e@80x24.org>
Wed, 4 Jan 2023 10:34:04 +0000 (10:34 +0000)
committerEric Wong <e@80x24.org>
Thu, 5 Jan 2023 09:58:55 +0000 (09:58 +0000)
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

index d8468b4fb381a16173b6459c68b23e28f1fa7b29..96627daa19735106f31308be686d8c37961661b4 100644 (file)
@@ -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
@@ -496,9 +497,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 {