summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b3a04ae)
Allowing ->init_bare to be used as a method saves some
keystrokes, and we can save a little bit of time on systems with
our vfork(2)-enabled spawn().
This also sets us up for future improvements where we can
avoid spawning a process at all.
23 files changed:
+ my ($dir) = @_; # or self
+ $dir = $dir->{git}->{git_dir} if ref($dir);
my @cmd = (qw(git init --bare -q), $dir);
run_die(\@cmd);
# set a reasonable default:
my @cmd = (qw(git init --bare -q), $dir);
run_die(\@cmd);
# set a reasonable default:
sub git_init {
my ($self, $epoch) = @_;
my $git_dir = "$self->{-inbox}->{inboxdir}/git/$epoch.git";
sub git_init {
my ($self, $epoch) = @_;
my $git_dir = "$self->{-inbox}->{inboxdir}/git/$epoch.git";
- my @cmd = (qw(git init --bare -q), $git_dir);
- PublicInbox::Import::run_die(\@cmd);
- @cmd = (qw/git config/, "--file=$git_dir/config",
+ PublicInbox::Import::init_bare($git_dir);
+ my @cmd = (qw/git config/, "--file=$git_dir/config",
'include.path', '../../all.git/config');
PublicInbox::Import::run_die(\@cmd);
fill_alternates($self, $epoch);
'include.path', '../../all.git/config');
PublicInbox::Import::run_die(\@cmd);
fill_alternates($self, $epoch);
use warnings;
use Test::More;
use PublicInbox::TestCommon;
use warnings;
use Test::More;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
use_ok 'PublicInbox::Admin', qw(resolve_repo_dir);
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/v1";
my $v2_dir = "$tmpdir/v2";
my ($res, $err, $v);
use_ok 'PublicInbox::Admin', qw(resolve_repo_dir);
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/v1";
my $v2_dir = "$tmpdir/v2";
my ($res, $err, $v);
-is(0, system(qw(git init -q --bare), $git_dir), 'git init v1');
+PublicInbox::Import::init_bare($git_dir);
# v1
is(resolve_repo_dir($git_dir), $git_dir, 'top-level GIT_DIR resolved');
# v1
is(resolve_repo_dir($git_dir), $git_dir, 'top-level GIT_DIR resolved');
- is(system(qw(git init -q --bare), $git_dir), 0, 'git init ok');
my $git = PublicInbox::Git->new($git_dir);
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
my $git = PublicInbox::Git->new($git_dir);
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
$im->add(Email::MIME->create(
header => [
From => 'a@example.com',
$im->add(Email::MIME->create(
header => [
From => 'a@example.com',
use Test::More;
use Email::MIME;
use PublicInbox::TestCommon;
use Test::More;
use Email::MIME;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
require_mods(qw(Plack::Handler::CGI Plack::Util));
my ($tmpdir, $for_destroy) = tmpdir();
my $home = "$tmpdir/pi-home";
require_mods(qw(Plack::Handler::CGI Plack::Util));
my ($tmpdir, $for_destroy) = tmpdir();
my $home = "$tmpdir/pi-home";
{
is(1, mkdir($home, 0755), "setup ~/ for testing");
is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox");
{
is(1, mkdir($home, 0755), "setup ~/ for testing");
is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox");
- is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
+ PublicInbox::Import::init_bare($maindir);
open my $fh, '>', "$maindir/description" or die "open: $!\n";
print $fh "test for public-inbox\n";
open my $fh, '>', "$maindir/description" or die "open: $!\n";
print $fh "test for public-inbox\n";
use Test::More;
use PublicInbox::Config;
use PublicInbox::TestCommon;
use Test::More;
use PublicInbox::Config;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
my ($tmpdir, $for_destroy) = tmpdir();
{
my ($tmpdir, $for_destroy) = tmpdir();
{
- is(system(qw(git init -q --bare), $tmpdir), 0, "git init successful");
+ PublicInbox::Import::init_bare($tmpdir);
my @cmd = ('git', "--git-dir=$tmpdir", qw(config foo.bar), "hi\nhi");
is(system(@cmd), 0, "set config");
my @cmd = ('git', "--git-dir=$tmpdir", qw(config foo.bar), "hi\nhi");
is(system(@cmd), 0, "set config");
-primary_address => 'test@example.com',
};
-primary_address => 'test@example.com',
};
-ok(PublicInbox::Import::run_die([qw(git init --bare -q), $ibx->{inboxdir}]),
- 'initialized v1 repo');
+PublicInbox::Import::init_bare($ibx->{inboxdir});
ok(umask(077), 'set restrictive umask');
ok(PublicInbox::Import::run_die([qw(git) , "--git-dir=$ibx->{inboxdir}",
qw(config core.sharedRepository 0644)]), 'set sharedRepository');
ok(umask(077), 'set restrictive umask');
ok(PublicInbox::Import::run_die([qw(git) , "--git-dir=$ibx->{inboxdir}",
qw(config core.sharedRepository 0644)]), 'set sharedRepository');
my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example');
{
my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example');
{
- is(0, system(qw(git init -q --bare), $git_dir), "git init");
local $ENV{GIT_DIR} = $git_dir;
foreach my $i (1..6) {
local $ENV{GIT_DIR} = $git_dir;
foreach my $i (1..6) {
use PublicInbox::TestCommon;
my ($dir, $for_destroy) = tmpdir();
use PublicInbox::Spawn qw(popen_rd);
use PublicInbox::TestCommon;
my ($dir, $for_destroy) = tmpdir();
use PublicInbox::Spawn qw(popen_rd);
+use PublicInbox::Import;
use_ok 'PublicInbox::Git';
{
use_ok 'PublicInbox::Git';
{
- is(system(qw(git init -q --bare), $dir), 0, 'created git directory');
+ PublicInbox::Import::init_bare($dir);
my $fi_data = './t/git.fast-import-data';
ok(-r $fi_data, "fast-import data readable (or run test at top level)");
local $ENV{GIT_DIR} = $dir;
my $fi_data = './t/git.fast-import-data';
ok(-r $fi_data, "fast-import data readable (or run test at top level)");
local $ENV{GIT_DIR} = $dir;
if ('alternates reloaded') {
my ($alt, $alt_obj) = tmpdir();
my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin));
if ('alternates reloaded') {
my ($alt, $alt_obj) = tmpdir();
my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin));
- is(system(qw(git init -q --bare), $alt), 0, 'create alt directory');
+ PublicInbox::Import::init_bare($alt);
open my $fh, '<', "$alt/config" or die "open failed: $!\n";
my $rd = popen_rd(\@cmd, {}, { 0 => $fh } );
close $fh or die "close failed: $!";
open my $fh, '<', "$alt/config" or die "open failed: $!\n";
my $rd = popen_rd(\@cmd, {}, { 0 => $fh } );
close $fh or die "close failed: $!";
- is(0, system(qw(git init -q --bare), $git_dir), "git init");
my $prev = "";
foreach my $i (1..6) {
my $prev = "";
foreach my $i (1..6) {
use PublicInbox::TestCommon;
my ($dir, $for_destroy) = tmpdir();
use PublicInbox::TestCommon;
my ($dir, $for_destroy) = tmpdir();
-is(system(qw(git init -q --bare), $dir), 0, 'git init successful');
my $git = PublicInbox::Git->new($dir);
my $git = PublicInbox::Git->new($dir);
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
my $mime = PublicInbox::MIME->create(
header => [
From => 'a@example.com',
my $mime = PublicInbox::MIME->create(
header => [
From => 'a@example.com',
use PublicInbox::Git;
use PublicInbox::InboxWritable;
use PublicInbox::TestCommon;
use PublicInbox::Git;
use PublicInbox::InboxWritable;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
my ($tmpdir, $for_destroy) = tmpdir();
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
my ($tmpdir, $for_destroy) = tmpdir();
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
"spamc mock found (run in top of source tree");
is(1, mkdir($home, 0755), "setup ~/ for testing");
is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox");
"spamc mock found (run in top of source tree");
is(1, mkdir($home, 0755), "setup ~/ for testing");
is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox");
- is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
+ PublicInbox::Import::init_bare($maindir);
open my $fh, '>>', $pi_config or die;
print $fh <<EOF or die;
open my $fh, '>>', $pi_config or die;
print $fh <<EOF or die;
my $git_dir = "$tmpdir/a.git";
{
my $git_dir = "$tmpdir/a.git";
{
- is(system(qw(git init -q --bare), $git_dir), 0, 'git init ok');
my $git = PublicInbox::Git->new($git_dir);
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
my $git = PublicInbox::Git->new($git_dir);
my $im = PublicInbox::Import->new($git, 'testbox', 'test@example');
$im->add(Email::MIME->create(
header => [
From => 'a@example.com',
$im->add(Email::MIME->create(
header => [
From => 'a@example.com',
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
-is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
my $git = PublicInbox::Git->new($maindir);
my $im = PublicInbox::Import->new($git, 'test', $addr);
my $git = PublicInbox::Git->new($maindir);
my $im = PublicInbox::Import->new($git, 'test', $addr);
{
open my $fh, '<', '/dev/urandom' or die "unable to open urandom: $!\n";
{
open my $fh, '<', '/dev/urandom' or die "unable to open urandom: $!\n";
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
-is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
my $git = PublicInbox::Git->new($maindir);
my $im = PublicInbox::Import->new($git, 'test', $addr);
my $git = PublicInbox::Git->new($maindir);
my $im = PublicInbox::Import->new($git, 'test', $addr);
{
my $mime = Email::MIME->new(<<EOF);
From: Me <me\@example.com>
{
my $mime = Email::MIME->new(<<EOF);
From: Me <me\@example.com>
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
EOF
-is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
+PublicInbox::Import::init_bare($maindir);
my $www = PublicInbox::WWW->new($config);
test_psgi(sub { $www->call(@_) }, sub {
my $www = PublicInbox::WWW->new($config);
test_psgi(sub { $www->call(@_) }, sub {
require PublicInbox::SearchIdx;
require PublicInbox::Smsg;
require PublicInbox::Inbox;
require PublicInbox::SearchIdx;
require PublicInbox::Smsg;
require PublicInbox::Inbox;
+use PublicInbox::Import;
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/a.git";
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/a.git";
-is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
+PublicInbox::Import::init_bare($git_dir);
my $ibx = PublicInbox::Inbox->new({inboxdir => $git_dir});
my $rw = PublicInbox::SearchIdx->new($ibx, 1);
ok($rw, "search indexer created");
my $ibx = PublicInbox::Inbox->new({inboxdir => $git_dir});
my $rw = PublicInbox::SearchIdx->new($ibx, 1);
ok($rw, "search indexer created");
require_mods(@psgi, 7 + scalar(@psgi));
use_ok($_) for @psgi;
my $binfoo = "$inboxdir/binfoo.git";
require_mods(@psgi, 7 + scalar(@psgi));
use_ok($_) for @psgi;
my $binfoo = "$inboxdir/binfoo.git";
- system(qw(git init --bare -q), $binfoo) == 0 or die "git init: $?";
+ require PublicInbox::Import;
+ PublicInbox::Import::init_bare($binfoo);
require_ok 'PublicInbox::ViewVCS';
my $big_size = do {
no warnings 'once';
require_ok 'PublicInbox::ViewVCS';
my $big_size = do {
no warnings 'once';
require_mods(qw(DBD::SQLite Search::Xapian));
require PublicInbox::SearchIdx;
my ($inboxdir, $for_destroy) = tmpdir();
require_mods(qw(DBD::SQLite Search::Xapian));
require PublicInbox::SearchIdx;
my ($inboxdir, $for_destroy) = tmpdir();
-is(system(qw(git init --bare -q), $inboxdir), 0);
my $ibx = {
inboxdir => $inboxdir,
name => 'test-add-remove-add',
my $ibx = {
inboxdir => $inboxdir,
name => 'test-add-remove-add',
body => "hello world\n",
);
my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
body => "hello world\n",
);
my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
ok($im->add($mime), 'message added');
ok($im->remove($mime), 'message removed');
ok($im->add($mime), 'message added again');
ok($im->add($mime), 'message added');
ok($im->remove($mime), 'message removed');
ok($im->add($mime), 'message added again');
use_ok 'PublicInbox::SearchIdx';
use_ok 'PublicInbox::Import';
my ($inboxdir, $for_destroy) = tmpdir();
use_ok 'PublicInbox::SearchIdx';
use_ok 'PublicInbox::Import';
my ($inboxdir, $for_destroy) = tmpdir();
-is(system(qw(git init -q --bare), $inboxdir), 0);
my $ibx_config = {
inboxdir => $inboxdir,
name => 'test-v1reindex',
my $ibx_config = {
inboxdir => $inboxdir,
name => 'test-v1reindex',
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
foreach my $i (1..10) {
$mime->header_set('Message-Id', "<$i\@example.com>");
ok($im->add($mime), "message $i added");
foreach my $i (1..10) {
$mime->header_set('Message-Id', "<$i\@example.com>");
ok($im->add($mime), "message $i added");
use Cwd;
use PublicInbox::Config;
use PublicInbox::TestCommon;
use Cwd;
use PublicInbox::Config;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
require_mods(qw(Filesys::Notify::Simple));
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/test.git";
require_mods(qw(Filesys::Notify::Simple));
my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/test.git";
use_ok 'PublicInbox::Emergency';
my $cfgpfx = "publicinbox.test";
my $addr = 'test-public@example.com';
use_ok 'PublicInbox::Emergency';
my $cfgpfx = "publicinbox.test";
my $addr = 'test-public@example.com';
-is(system(qw(git init -q --bare), $git_dir), 0, 'initialized git dir');
+PublicInbox::Import::init_bare($git_dir);
my $msg = <<EOF;
From: user\@example.com
my $msg = <<EOF;
From: user\@example.com
use Cwd;
use PublicInbox::Config;
use PublicInbox::TestCommon;
use Cwd;
use PublicInbox::Config;
use PublicInbox::TestCommon;
+use PublicInbox::Import;
require_git(2.6);
require_mods(qw(Search::Xapian DBD::SQLite Filesys::Notify::Simple));
require PublicInbox::V2Writable;
require_git(2.6);
require_mods(qw(Search::Xapian DBD::SQLite Filesys::Notify::Simple));
require PublicInbox::V2Writable;
my $v1repo = "$tmpdir/v1";
my $v1pfx = "publicinbox.v1";
my $v1addr = 'v1-public@example.com';
my $v1repo = "$tmpdir/v1";
my $v1pfx = "publicinbox.v1";
my $v1addr = 'v1-public@example.com';
- is(system(qw(git init -q --bare), $v1repo), 0, 'v1 init OK');
+ PublicInbox::Import::init_bare($v1repo);
my $cfg2 = <<EOF;
$orig$v1pfx.address=$v1addr
$v1pfx.inboxdir=$v1repo
my $cfg2 = <<EOF;
$orig$v1pfx.address=$v1addr
$v1pfx.inboxdir=$v1repo
use Test::More;
use PublicInbox::Spawn qw(which);
use PublicInbox::TestCommon;
use Test::More;
use PublicInbox::Spawn qw(which);
use PublicInbox::TestCommon;
+use PublicInbox::Import;
require_mods(qw(URI::Escape Plack::Builder Digest::SHA
IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny));
require PublicInbox::WwwListing;
require_mods(qw(URI::Escape Plack::Builder Digest::SHA
IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny));
require PublicInbox::WwwListing;
my ($tmpdir, $for_destroy) = tmpdir();
my $bare = PublicInbox::Git->new("$tmpdir/bare.git");
my ($tmpdir, $for_destroy) = tmpdir();
my $bare = PublicInbox::Git->new("$tmpdir/bare.git");
-is(system(qw(git init -q --bare), $bare->{git_dir}), 0, 'git init --bare');
+PublicInbox::Import::init_bare($bare->{git_dir});
is(PublicInbox::WwwListing::fingerprint($bare), undef,
'empty repo has no fingerprint');
{
is(PublicInbox::WwwListing::fingerprint($bare), undef,
'empty repo has no fingerprint');
{
my @clone = qw(git clone -q -s --bare);
is(system(@clone, $bare->{git_dir}, $alt), 0, 'clone shared repo');
my @clone = qw(git clone -q -s --bare);
is(system(@clone, $bare->{git_dir}, $alt), 0, 'clone shared repo');
- system(qw(git init --bare -q), "$v2/all.git") == 0 or die;
+ PublicInbox::Import::init_bare("$v2/all.git");
for my $i (0..2) {
is(system(@clone, $alt, "$v2/git/$i.git"), 0, "clone epoch $i");
}
for my $i (0..2) {
is(system(@clone, $alt, "$v2/git/$i.git"), 0, "clone epoch $i");
}