user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH] init: do not set publicinbox.$NAME.indexlevel by default
Date: Tue, 25 Dec 2018 03:44:57 +0000	[thread overview]
Message-ID: <20181225034457.v6oukmmh6rn25gmj@dcvr> (raw)

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;
+}

                 reply	other threads:[~2018-12-25  3:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181225034457.v6oukmmh6rn25gmj@dcvr \
    --to=e@80x24.org \
    --cc=ebiederm@xmission.com \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).