about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-14 02:04:41 +0000
committerEric Wong <e@80x24.org>2019-05-14 02:05:55 +0000
commitfdfd7161a9257b70d65ab55dba4328b4960142d3 (patch)
treece3fe2b0a13c62931f8e4b039f3f73c38561a8dd /lib/PublicInbox/Import.pm
parent7e2abe2d068367f2fcdf638a4482c953111df156 (diff)
downloadpublic-inbox-fdfd7161a9257b70d65ab55dba4328b4960142d3.tar.gz
Import initialization is a little strange from history, but we
also can't change it too much because it's technically a public
API which external code may rely on...

And we may need to support v1 repos indefinitely.  This should
make it easier to write tests for both formats.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index c7755755..12abf399 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -18,12 +18,15 @@ use PublicInbox::MDA;
 use POSIX qw(strftime);
 
 sub new {
+        # we can't change arg order, this is documented in POD
+        # and external projects may rely on it:
         my ($class, $git, $name, $email, $ibx) = @_;
         my $ref = 'refs/heads/master';
         if ($ibx) {
                 $ref = $ibx->{ref_head} || 'refs/heads/master';
                 $name ||= $ibx->{name};
                 $email ||= $ibx->{-primary_address};
+                $git ||= $ibx->git;
         }
         bless {
                 git => $git,
@@ -433,6 +436,16 @@ sub run_die ($;$$) {
         $? == 0 or die join(' ', @$cmd) . " failed: $?\n";
 }
 
+sub init_bare {
+        my ($dir) = @_;
+        my @cmd = (qw(git init --bare -q), $dir);
+        run_die(\@cmd);
+        # set a reasonable default:
+        @cmd = (qw/git config/, "--file=$dir/config",
+                'repack.writeBitmaps', 'true');
+        run_die(\@cmd);
+}
+
 sub done {
         my ($self) = @_;
         my $w = delete $self->{out} or return;
@@ -586,7 +599,7 @@ __END__
 
 =head1 NAME
 
-PublicInbox::Import - message importer for public-inbox
+PublicInbox::Import - message importer for public-inbox v1 inboxes
 
 =head1 VERSION