about summary refs log tree commit homepage
path: root/lib/PublicInbox/WWW.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-27 20:31:44 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-27 21:20:01 +0000
commit7b5ea579e6a9490a4a38958acac8e078d805eec7 (patch)
tree28e99dd0ee8c6740ed0f5aaf22837db31ca983cd /lib/PublicInbox/WWW.pm
parenta966564fef08a4f25670778efbff139fbbf47c84 (diff)
downloadpublic-inbox-7b5ea579e6a9490a4a38958acac8e078d805eec7.tar.gz
This will require multiple client invocations, but should reduce
load on the server and make it easier for readers to only clone
the latest data.

Unfortunately, supporting a cloneurl file for externally-hosted
repos will be more difficult as we cannot easily know if the
clones use v1 or v2 repositories, or how many git partitions
they have.
Diffstat (limited to 'lib/PublicInbox/WWW.pm')
-rw-r--r--lib/PublicInbox/WWW.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index a2c2a4a6..7bd29732 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -54,10 +54,10 @@ sub call {
         my $method = $env->{REQUEST_METHOD};
 
         if ($method eq 'POST') {
-                if ($path_info =~ m!$INBOX_RE/(git-upload-pack)\z!) {
-                        my $path = $2;
+                if ($path_info =~ m!$INBOX_RE/(?:(\d+)/)?(git-upload-pack)\z!) {
+                        my ($part, $path) = ($2, $3);
                         return invalid_inbox($ctx, $1) ||
-                                serve_git($ctx, $path);
+                                serve_git($ctx, $part, $path);
                 } elsif ($path_info =~ m!$INBOX_RE/!o) {
                         return invalid_inbox($ctx, $1) || mbox_results($ctx);
                 }
@@ -77,10 +77,10 @@ sub call {
                 invalid_inbox($ctx, $1) || get_atom($ctx);
         } elsif ($path_info =~ m!$INBOX_RE/new\.html\z!o) {
                 invalid_inbox($ctx, $1) || get_new($ctx);
-        } elsif ($path_info =~ m!$INBOX_RE/
+        } elsif ($path_info =~ m!$INBOX_RE/(?:(\d+)/)?
                                 ($PublicInbox::GitHTTPBackend::ANY)\z!ox) {
-                my $path = $2;
-                invalid_inbox($ctx, $1) || serve_git($ctx, $path);
+                my ($part, $path) = ($2, $3);
+                invalid_inbox($ctx, $1) || serve_git($ctx, $part, $path);
         } elsif ($path_info =~ m!$INBOX_RE/([\w-]+).mbox\.gz\z!o) {
                 serve_mbox_range($ctx, $1, $2);
         } elsif ($path_info =~ m!$INBOX_RE/$MID_RE/$END_RE\z!o) {
@@ -393,8 +393,11 @@ sub msg_page {
 }
 
 sub serve_git {
-        my ($ctx, $path) = @_;
-        PublicInbox::GitHTTPBackend::serve($ctx->{env}, $ctx->{git}, $path);
+        my ($ctx, $part, $path) = @_;
+        my $env = $ctx->{env};
+        my $ibx = $ctx->{-inbox};
+        my $git = defined $part ? $ibx->git_part($part) : $ibx->git;
+        $git ? PublicInbox::GitHTTPBackend::serve($env, $git, $path) : r404();
 }
 
 sub mbox_results {