about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-10-04 19:12:35 +0000
committerEric Wong <e@80x24.org>2022-10-05 21:15:26 +0000
commit6dec9bf8c0e1b859703d7a5dfb87052cf4e87846 (patch)
tree7d0e0c7bf96da3a3fe494eaaaaf1c714b5aa1775 /lib/PublicInbox/Git.pm
parenta002384a74382df2649d6a1f8dfba4f291af032e (diff)
downloadpublic-inbox-6dec9bf8c0e1b859703d7a5dfb87052cf4e87846.tar.gz
This will allow it to easily map a single coderepo to multiple
inboxes (or multiple coderepos to any number of inboxes).
For now, this is just a summary, but $REPO/$OID/s/ support
will be added, along with archive downloads.

Indexing of coderepos will probably be supported via -extindex,
only.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 2f0bb6a0..395add1f 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -463,6 +463,16 @@ sub host_prefix_url ($$) {
         "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url;
 }
 
+sub base_url { # for coderepos, PSGI-only
+        my ($self, $env) = @_; # env - PSGI env
+        my $url = host_prefix_url($env, '');
+        # for mount in Plack::Builder
+        $url .= '/' if substr($url, -1, 1) ne '/';
+        $url . $self->{nick} . '/';
+}
+
+sub isrch {} # TODO
+
 sub pub_urls {
         my ($self, $env) = @_;
         if (my $urls = $self->{cgit_url}) {
@@ -518,11 +528,11 @@ sub description {
 }
 
 sub cloneurl {
-        my ($self) = @_;
+        my ($self, $env) = @_;
         $self->{cloneurl} // do {
                 my @urls = split(/\s+/s, try_cat("$self->{git_dir}/cloneurl"));
                 scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef;
-        } // [];
+        } // [ substr(base_url($self, $env), 0, -1) ];
 }
 
 # for grokmirror, which doesn't read gitweb.description