]> Sergey Matveev's repositories - public-inbox.git/commitdiff
clone: support --inbox-config option
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:21 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:54 +0000 (23:38 +0000)
This allows avoiding 404s when trying _/text/config/raw on code
repositories.

Documentation/public-inbox-clone.pod
lib/PublicInbox/LeiMirror.pm
script/public-inbox-clone

index 178d952ad8fb1089ff09d4cc4d8abdc718341013..52c89cfd1d97bffc5e7a6ecf892cb408aa08c457 100644 (file)
@@ -65,6 +65,17 @@ When cloning a top-level with multiple inboxes, ignore inboxes and
 repositories matching the given wildcard pattern.  Supports the same
 wildcards as L</--include>
 
+=item --inbox-config=always|v2|v1|never
+
+Whether or not to retrieve the C<$INBOX/_/text/config/raw> HTTP(S)
+endpoint when cloning.
+
+Since we can't deduce v1 inboxes from code repositories, setting this
+to C<v2> or C<never> can allow faster clones of code repositories if
+no v1 inboxes are present.
+
+Default: C<always>
+
 =item -n
 
 =item --dry-run
index f81f609469bcf788b474248ce70b9936d3055fca..44d7a5240781fb338f9b1c7c733cf5b461f47957 100644 (file)
@@ -259,7 +259,8 @@ sub clone_v1 {
                push @$cmd, '--reference', "$self->{dst}$ref";
        start_clone($self, $cmd, $opt, $fini);
 
-       _get_txt_start($self, '_/text/config/raw', $fini);
+       $lei->{opt}->{'inbox-config'} =~ /\A(?:always|v1)\z/s and
+               _get_txt_start($self, '_/text/config/raw', $fini);
        my $d = $self->{-ent} ? $self->{-ent}->{description} : undef;
        defined($d) ? ($self->{'txt.description'} = $d) :
                _get_txt_start($self, 'description', $fini);
@@ -445,7 +446,9 @@ failed to extract epoch number from $src
        my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock';
        my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task);
 
-       _get_txt_start($task, '_/text/config/raw', $fini);
+       $lei->{opt}->{'inbox-config'} =~ /\A(?:always|v2)\z/s and
+               _get_txt_start($task, '_/text/config/raw', $fini);
+
        _get_txt_start($self, 'description', $fini);
 
        $task->{-locked} = $lk->lock_for_scope($$) if !$self->{dry_run};
@@ -649,11 +652,15 @@ sub start_clone_url {
        die "TODO: non-HTTP/HTTPS clone of $self->{src} not supported, yet";
 }
 
-sub do_mirror { # via wq_io_do
+sub do_mirror { # via wq_io_do or public-inbox-clone
        my ($self) = @_;
        my $lei = $self->{lei};
        umask($lei->{client_umask}) if defined $lei->{client_umask};
        eval {
+               my $ic = $lei->{opt}->{'inbox-config'} //= 'always';
+               $ic =~ /\A(?:v1|v2|always|never)\z/s or die <<"";
+--inbox-config must be one of `always', `v2', `v1', or `never'
+
                my $iv = $lei->{opt}->{'inbox-version'};
                if (defined $iv) {
                        local $LIVE;
index 22ffc0fcded1309610b55ddc08ec1a11b0745542..3d980c97da779a3ca2d69489d48ebc357fbd9595 100755 (executable)
@@ -23,6 +23,7 @@ options:
     -C DIR            chdir to specified directory
 EOF
 GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@
+       inbox-config=s
        dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help;
 if ($opt->{help}) { print $help; exit };
 require PublicInbox::Admin; # loads Config