From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/4] www: support $INBOX/git/$EPOCH.git for v2 cloning
Date: Sun, 9 Jun 2019 04:31:05 +0000 [thread overview]
Message-ID: <20190609043105.22338-5-e@80x24.org> (raw)
In-Reply-To: <20190609043105.22338-1-e@80x24.org>
And use it in manifest.js.
To ease maintaining mirrors with grokmirror(1), we can accept
a "git/" directory prefix before the epoch, and ".git" suffix
after the epoch number.
We maintain compatibility with "$INBOX/$EPOCH" cloning, of
course, and it's still easier-to-type on the command-line.
---
lib/PublicInbox/WWW.pm | 4 ++--
lib/PublicInbox/WwwListing.pm | 2 +-
t/psgi_v2.t | 2 ++
t/v2mirror.t | 8 +++++---
t/www_listing.t | 6 +++---
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index a546698..e468263 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -74,7 +74,7 @@ sub call {
my $method = $env->{REQUEST_METHOD};
if ($method eq 'POST') {
- if ($path_info =~ m!$INBOX_RE/(?:([0-9]+)/)?
+ if ($path_info =~ m!$INBOX_RE/(?:(?:git/)?([0-9]+)(?:\.git)?/)?
(git-upload-pack)\z!x) {
my ($part, $path) = ($2, $3);
return invalid_inbox($ctx, $1) ||
@@ -98,7 +98,7 @@ 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/(?:([0-9]+)/)?
+ } elsif ($path_info =~ m!$INBOX_RE/(?:(?:git/)?([0-9]+)(?:\.git)?/)?
($PublicInbox::GitHTTPBackend::ANY)\z!ox) {
my ($part, $path) = ($2, $3);
invalid_inbox($ctx, $1) || serve_git($ctx, $part, $path);
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 690976a..e2724cc 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -144,7 +144,7 @@ sub manifest_add ($$;$) {
my $git_dir = $ibx->{mainrepo};
if (defined $epoch) {
$git_dir .= "/git/$epoch.git";
- $url_path .= "/$epoch";
+ $url_path .= "/git/$epoch.git";
}
return unless -d $git_dir;
my $git = PublicInbox::Git->new($git_dir);
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 9811249..5c358cd 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -202,6 +202,8 @@ test_psgi(sub { $www->call(@_) }, sub {
$res = $cb->(GET('/v2test/0/info/refs'));
is($res->code, 200, 'got info refs for dumb clones');
+ $res = $cb->(GET('/v2test/0.git/info/refs'));
+ is($res->code, 200, 'got info refs for dumb clones w/ .git suffix');
$res = $cb->(GET('/v2test/info/refs'));
is($res->code, 404, 'unpartitioned git URL fails');
diff --git a/t/v2mirror.t b/t/v2mirror.t
index fe05ec4..c31dcd5 100644
--- a/t/v2mirror.t
+++ b/t/v2mirror.t
@@ -80,11 +80,13 @@ $sock = undef;
my @cmd;
foreach my $i (0..$epoch_max) {
- @cmd = (qw(git clone --mirror -q), "http://$host:$port/v2/$i",
+ my $sfx = $i == 0 ? '.git' : '';
+ @cmd = (qw(git clone --mirror -q),
+ "http://$host:$port/v2/$i$sfx",
"$tmpdir/m/git/$i.git");
- is(system(@cmd), 0, 'cloned OK');
- ok(-d "$tmpdir/m/git/$i.git", 'mirror OK');
+ is(system(@cmd), 0, "cloned $i.git");
+ ok(-d "$tmpdir/m/git/$i.git", "mirror $i OK");
}
@cmd = ("$script-init", '-V2', 'm', "$tmpdir/m", 'http://example.com/m',
diff --git a/t/www_listing.t b/t/www_listing.t
index 546c2f8..2741e1b 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -111,7 +111,7 @@ SKIP: {
is(HTTP::Date::time2str($bare->{modified}), $h{'Last-Modified'},
'modified field and Last-Modified header match');
- ok($manifest->{'/v2/0'}, 'v2 epoch appeared');
+ ok($manifest->{'/v2/git/0.git'}, 'v2 epoch appeared');
skip 'skipping grok-pull integration test', 2 if !which('grok-pull');
@@ -130,7 +130,7 @@ mymanifest = $tmpdir/local-manifest.js.gz
system(qw(grok-pull -c), "$tmpdir/repos.conf");
is($? >> 8, 127, 'grok-pull exit code as expected');
- for (qw(alt bare v2/0 v2/1 v2/2)) {
+ for (qw(alt bare v2/git/0.git v2/git/1.git v2/git/2.git)) {
ok(-d "$tmpdir/mirror/$_", "grok-pull created $_");
}
@@ -150,7 +150,7 @@ mymanifest = $tmpdir/per-inbox-manifest.js.gz
ok(mkdir("$tmpdir/per-inbox"), 'prepare single-v2-inbox mirror');
system(qw(grok-pull -c), "$tmpdir/per-inbox.conf");
is($? >> 8, 127, 'grok-pull exit code as expected');
- for (qw(v2/0 v2/1 v2/2)) {
+ for (qw(v2/git/0.git v2/git/1.git v2/git/2.git)) {
ok(-d "$tmpdir/per-inbox/$_", "grok-pull created $_");
}
}
--
EW
next prev parent reply other threads:[~2019-06-09 4:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-09 4:31 [PATCH 0/4] grokmirror-compatible manifests Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 ` [PATCH 1/4] wwwlisting: allow hiding entries from manifest Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 ` [PATCH 2/4] wwwlisting: generate grokmirror-compatible manifest.js.gz Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 ` [PATCH 3/4] www: wire up /$INBOX/manifest.js.gz, too Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2019-06-10 6:21 ` [PATCH 5/4] git: ensure ->modified returns an integer Eric Wong (Contractor, The Linux Foundation)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190609043105.22338-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).