From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E36811FB07 for ; Sun, 12 Sep 2021 07:47:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/7] init: set a useful description Date: Sun, 12 Sep 2021 07:47:15 +0000 Message-Id: <20210912074716.4713-7-e@80x24.org> In-Reply-To: <20210912074716.4713-1-e@80x24.org> References: <20210912074716.4713-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: "Unnamed repository" for v1 inboxes was misleading, and having a non-existent description for v2 was equally annoying, so set a short description based on the primary address. We remove descriptions when setting up new test inboxes to preserve the behavior of the t/lei-mirror.t test case. --- lib/PublicInbox/TestCommon.pm | 3 ++- script/public-inbox-init | 6 ++++++ t/init.t | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 2e3e9ecc..14dac03f 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -605,7 +605,8 @@ sub setup_public_inboxes () { run_script([qw(-init --skip-docdata), "-V$V", '--newsgroup', "t.v$V", "t$V", "$test_home/t$V", "http://example.com/t$V", - "t$V\@example.com" ]) or BAIL_OUT "init v$V"; + "t$V\@example.com" ]) or xbail "init v$V"; + unlink "$test_home/t$V/description" or xbail "unlink $!"; } require PublicInbox::Config; require PublicInbox::InboxWritable; diff --git a/script/public-inbox-init b/script/public-inbox-init index ced88235..78a4d3bd 100755 --- a/script/public-inbox-init +++ b/script/public-inbox-init @@ -246,3 +246,9 @@ if (defined $perm) { rename $pi_config_tmp, $pi_config or die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n"; undef $auto_unlink; # trigger ->DESTROY + +my $f = "$inboxdir/description"; +if (sysopen $fh, $f, O_CREAT|O_EXCL|O_WRONLY) { + print $fh "public inbox for $address[0]\n" or die "print($f): $!"; + close $fh or die "close($f): $!"; +} diff --git a/t/init.t b/t/init.t index efa3314d..752e5af9 100644 --- a/t/init.t +++ b/t/init.t @@ -99,6 +99,9 @@ sub quiet_fail { $err = ''; ok(run_script($cmd, $env, $rdr), 'initializes non-existent hierarchy'); ok(-d "$tmpdir/a/b/c/d", 'directory created'); + is(PublicInbox::Inbox::try_cat("$tmpdir/a/b/c/d/description"), + "public inbox for abcd\@example.com\n", 'description set'); + open my $fh, '>', "$tmpdir/d" or BAIL_OUT "open: $!"; close $fh; $cmd = [ '-init', 'd-f-conflict', "$tmpdir/d/f/conflict",