user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] init: do not set publicinbox.$NAME.indexlevel by default
@ 2018-12-25  3:44 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2018-12-25  3:44 UTC (permalink / raw)
  To: meta; +Cc: Eric W. Biederman

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 |  6 ++++--
 t/init.t                 | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/script/public-inbox-init b/script/public-inbox-init
index 5e961c8..1aec799 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -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";
diff --git a/t/init.t b/t/init.t
index 59f5481..182d065 100644
--- 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;
+}

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-25  3:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-25  3:44 [PATCH] init: do not set publicinbox.$NAME.indexlevel by default Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).