]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www_stream: use git->pub_urls for coderepo links
authorEric Wong <e@80x24.org>
Tue, 4 Oct 2022 19:12:39 +0000 (19:12 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 Oct 2022 21:15:46 +0000 (21:15 +0000)
This is already used by */$OID/s/, so just reuse existing code
and make git->local_nick use the assigned nick from the config
file, if there is one.

lib/PublicInbox/Git.pm
lib/PublicInbox/WwwStream.pm

index 2ed3a29bcd6fdafa2b453a4979b66f82b0f5d37e..882a9a4ac28815f3dbc920e3344b78781edb9a7d 100644 (file)
@@ -452,7 +452,8 @@ sub DESTROY { cleanup(@_) }
 
 sub local_nick ($) {
        # don't show full FS path, basename should be OK:
-       $_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? "$1.git" : undef;
+       $_[0]->{nick} // ($_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ?
+                       "$1.git" : undef);
 }
 
 sub host_prefix_url ($$) {
index 92d243eb09fd172e6cfcc1d25575e94d246dd5a3..f5b4df9fe061886b08bca636052b5e02b8f9472f 100644 (file)
@@ -98,16 +98,13 @@ sub coderepos ($) {
        my @ret = ('<a id=code>' .
                'Code repositories for project(s) associated with this '.
                $ctx->{ibx}->thing_type . "\n");
-       for my $cr_name (@$cr) {
-               my $urls = $cfg->get_all("coderepo.$cr_name.cgiturl");
-               if ($urls) {
-                       for (@$urls) {
-                               my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $pfx.$_;
-                               $u = ascii_html(prurl($ctx->{env}, $u));
-                               $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>);
-                       }
-               } else {
-                       $ret[0] .= qq[\n\t$cr_name.git (no URL configured)];
+       my $objs = $cfg->repo_objs($ctx->{ibx});
+       for my $git (@$objs) {
+               my @urls = $git->pub_urls($ctx->{env});
+               for (@urls) {
+                       my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $pfx.$_;
+                       $u = ascii_html(prurl($ctx->{env}, $u));
+                       $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>);
                }
        }
        @ret; # may be empty, this sub is called as an arg for join()