]> Sergey Matveev's repositories - public-inbox.git/commitdiff
init: set a useful description
authorEric Wong <e@80x24.org>
Sun, 12 Sep 2021 07:47:15 +0000 (07:47 +0000)
committerEric Wong <e@80x24.org>
Sun, 12 Sep 2021 07:48:58 +0000 (07:48 +0000)
"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
script/public-inbox-init
t/init.t

index 2e3e9eccce7980d424368e3337ee83bb0c3a4e54..14dac03fae54ed78cffb417c59af59005ffaf93d 100644 (file)
@@ -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;
index ced882359870bcf183df91833e4bf126fb4a6974..78a4d3bd75748f65110bb3e8af18c7d4fc976df8 100755 (executable)
@@ -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): $!";
+}
index efa3314d365b03c049a9c2939b2529992d2a6874..752e5af93c0b60ce519cf838331494a2d5c8c472 100644 (file)
--- 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",