]> Sergey Matveev's repositories - public-inbox.git/commitdiff
convert+compact: fix when running without ~/.public-inbox/config
authorEric Wong <e@80x24.org>
Fri, 11 May 2018 19:20:16 +0000 (19:20 +0000)
committerEric Wong <e@80x24.org>
Fri, 11 May 2018 19:23:08 +0000 (19:23 +0000)
Some users may not have any public-inboxes configured, especially in
tests.

script/public-inbox-compact
script/public-inbox-convert
t/convert-compact.t

index 5f18497e6b57558963e30562565d3c2798836202..d22e40323dfef08b513aea2d8a4c95f0137dc5a1 100755 (executable)
@@ -13,12 +13,14 @@ use File::Path qw(remove_tree);
 use PublicInbox::Spawn qw(spawn);
 my $usage = "Usage: public-inbox-compact REPO_DIR\n";
 my $dir = shift or die $usage;
-my $config = PublicInbox::Config->new;
+my $config = eval { PublicInbox::Config->new };
 my $ibx;
 $dir = abs_path($dir);
-$config->each_inbox(sub {
-       $ibx = $_[0] if abs_path($_[0]->{mainrepo}) eq $dir
-});
+if ($config) {
+       $config->each_inbox(sub {
+               $ibx = $_[0] if abs_path($_[0]->{mainrepo}) eq $dir
+       });
+}
 unless ($ibx) {
        warn "W: $dir not configured in ".
                PublicInbox::Config::default_file() . "\n";
index 2979a0c80b06ac365885c707fae7112a4bd1435f..bd8fb9855b1eeee7617553c54845340afa2a458c 100755 (executable)
@@ -25,12 +25,14 @@ my $old_dir = shift or die $usage;
 my $new_dir = shift or die $usage;
 die "$new_dir exists\n" if -d $new_dir;
 die "$old_dir not a directory\n" unless -d $old_dir;
-my $config = PublicInbox::Config->new;
+my $config = eval { PublicInbox::Config->new };
 $old_dir = abs_path($old_dir);
 my $old;
-$config->each_inbox(sub {
-       $old = $_[0] if abs_path($_[0]->{mainrepo}) eq $old_dir;
-});
+if ($config) {
+       $config->each_inbox(sub {
+               $old = $_[0] if abs_path($_[0]->{mainrepo}) eq $old_dir;
+       });
+}
 unless ($old) {
        warn "W: $old_dir not configured in " .
                PublicInbox::Config::default_file() . "\n";
index ced45415e70c580227a5f58ec0b1b4e18669ec81..e92320037003a6d9c3c7dde014e938c4634164e1 100644 (file)
@@ -54,6 +54,7 @@ foreach (@xdir) {
 }
 
 local $ENV{PATH} = "blib/script:$ENV{PATH}";
+local $ENV{PI_CONFIG} = '/dev/null';
 open my $err, '>>', "$tmpdir/err.log" or die "open: err.log $!\n";
 open my $out, '>>', "$tmpdir/out.log" or die "open: out.log $!\n";
 my $rdr = { 1 => fileno($out), 2 => fileno($err) };