]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
init: do not set publicinbox.$NAME.indexlevel by default
authorEric Wong <e@80x24.org>
Tue, 25 Dec 2018 03:44:57 +0000 (03:44 +0000)
committerEric Wong <e@80x24.org>
Thu, 27 Dec 2018 23:56:15 +0000 (23:56 +0000)
It is redundant to set default values in the public-inbox
config file.  Lets not clutter up users' screens when they
view or edit the config file.

script/public-inbox-init
t/init.t

index 5e961c803203b810876ca0a271a890360b89021a..1aec799c60cc2a24dcf2bb3b8597e54d2e677e9b 100755 (executable)
@@ -76,7 +76,6 @@ if (-e $pi_config) {
        }
 }
 close $fh or die "failed to close $pi_config_tmp: $!\n";
-$indexlevel ||= 'full';
 
 my $pfx = "publicinbox.$name";
 my @x = (qw/git config/, "--file=$pi_config_tmp");
@@ -125,7 +124,10 @@ foreach my $addr (@address) {
 }
 x(@x, "$pfx.url", $http_url);
 x(@x, "$pfx.mainrepo", $mainrepo);
-x(@x, "$pfx.indexlevel", $indexlevel);
+
+if (defined($indexlevel)) {
+       x(@x, "$pfx.indexlevel", $indexlevel);
+}
 
 rename $pi_config_tmp, $pi_config or
        die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
index 59f54813f6ae5a035aea6de3778bb81d6e5d1b8c..182d065cb66461e9037c4fdb832834fb153e2456 100644 (file)
--- a/t/init.t
+++ b/t/init.t
@@ -32,6 +32,8 @@ sub quiet_fail {
                   qw(http://example.com/blist blist@example.com));
        is(system(@cmd), 0, 'public-inbox-init OK');
 
+       is(read_indexlevel('blist'), '', 'indexlevel unset by default');
+
        ok(-e $cfgfile, "config exists, now");
        is(system(@cmd), 0, 'public-inbox-init OK (idempotent)');
 
@@ -64,10 +66,26 @@ SKIP: {
        is(system(@cmd), 0, 'public-inbox-init is idempotent');
        ok(! -d "$tmpdir/public-inbox" && !-d "$tmpdir/objects",
                'idempotent invocation w/o -V2 does not make inbox v1');
+       is(read_indexlevel('v2list'), '', 'indexlevel unset by default');
 
        @cmd = (pi_init, 'v2list', "-V1", "$tmpdir/v2list",
                   qw(http://example.com/v2list v2list@example.com));
        quiet_fail(\@cmd, 'initializing V2 as V1 fails');
+
+       foreach my $lvl (qw(medium basic)) {
+               @cmd = (pi_init, "v2$lvl", '-V2', '-L', $lvl,
+                       "$tmpdir/v2$lvl", "http://example.com/v2$lvl",
+                       "v2$lvl\@example.com");
+               is(system(@cmd), 0, "-init -L $lvl");
+               is(read_indexlevel("v2$lvl"), $lvl, "indexlevel set to '$lvl'");
+       }
 }
 
 done_testing();
+
+sub read_indexlevel {
+       my ($inbox) = @_;
+       local $ENV{GIT_CONFIG} = "$ENV{PI_DIR}/config";
+       chomp(my $lvl = `git config publicinbox.$inbox.indexlevel`);
+       $lvl;
+}