user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/7] init: set a useful description
Date: Sun, 12 Sep 2021 07:47:15 +0000	[thread overview]
Message-ID: <20210912074716.4713-7-e@80x24.org> (raw)
In-Reply-To: <20210912074716.4713-1-e@80x24.org>

"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",

  parent reply	other threads:[~2021-09-12  7:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-12  7:47 [PATCH 0/7] new public-inbox-{clone,fetch} commands Eric Wong
2021-09-12  7:47 ` [PATCH 1/7] lei_mirror: simplify error reporting Eric Wong
2021-09-12  7:47 ` [PATCH 2/7] lei_mirror: fix error message Eric Wong
2021-09-12  7:47 ` [PATCH 3/7] new public-inbox-{clone,fetch} commands Eric Wong
2021-09-12  7:47 ` [PATCH 4/7] clone|lei_mirror: write description in mirrors Eric Wong
2021-09-12  7:47 ` [PATCH 5/7] import: do not write a "description" file Eric Wong
2021-09-12  7:47 ` Eric Wong [this message]
2021-09-12  7:47 ` [PATCH 7/7] fetch: use manifest.js.gz for v1 Eric Wong

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=20210912074716.4713-7-e@80x24.org \
    --to=e@80x24.org \
    --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).