* [PATCH 4/4] www: support $INBOX/git/$EPOCH.git for v2 cloning
2019-06-09 4:31 6% [PATCH 0/4] grokmirror-compatible manifests Eric Wong (Contractor, The Linux Foundation)
@ 2019-06-09 4:31 7% ` Eric Wong (Contractor, The Linux Foundation)
0 siblings, 0 replies; 2+ results
From: Eric Wong (Contractor, The Linux Foundation) @ 2019-06-09 4:31 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [relevance 7%]
* [PATCH 0/4] grokmirror-compatible manifests
@ 2019-06-09 4:31 6% Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 7% ` [PATCH 4/4] www: support $INBOX/git/$EPOCH.git for v2 cloning Eric Wong (Contractor, The Linux Foundation)
0 siblings, 1 reply; 2+ results
From: Eric Wong (Contractor, The Linux Foundation) @ 2019-06-09 4:31 UTC (permalink / raw)
To: meta
Maintaining mirrors is a pain, especially for v2 repos
and multiple epochs. So support both per-domain matching
and per-inbox manifests which can be fed to grok-pull(1)
https://git.kernel.org/pub/scm/utils/grokmirror/grokmirror.git
Eric Wong (Contractor, The Linux Foundation) (4):
wwwlisting: allow hiding entries from manifest
wwwlisting: generate grokmirror-compatible manifest.js.gz
www: wire up /$INBOX/manifest.js.gz, too
www: support $INBOX/git/$EPOCH.git for v2 cloning
MANIFEST | 1 +
lib/PublicInbox/WWW.pm | 17 +++-
lib/PublicInbox/WwwListing.pm | 174 +++++++++++++++++++++++++++++-----
t/psgi_v2.t | 2 +
t/v2mirror.t | 8 +-
t/www_listing.t | 158 ++++++++++++++++++++++++++++++
6 files changed, 330 insertions(+), 30 deletions(-)
create mode 100644 t/www_listing.t
--
EW
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-09 4:31 6% [PATCH 0/4] grokmirror-compatible manifests Eric Wong (Contractor, The Linux Foundation)
2019-06-09 4:31 7% ` [PATCH 4/4] www: support $INBOX/git/$EPOCH.git for v2 cloning Eric Wong (Contractor, The Linux Foundation)
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).