user/dev discussion of public-inbox itself
 help / color / 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	[flat|nested] only message in thread

only message in thread, back to index

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

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox