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 5/6] admin: resolve_repo_dir => resolve_inboxdir
Date: Tue,  8 Dec 2020 21:21:29 +0000	[thread overview]
Message-ID: <20201208212130.5832-6-e@80x24.org> (raw)
In-Reply-To: <20201208212130.5832-1-e@80x24.org>

We've stopped referring to inboxdirs as "repos" a while ago
since v2 inboxes have multiple git repos associated with them.

So update the name to reflect that and avoid an unnecessary
export that's only used by a test case.
---
 lib/PublicInbox/Admin.pm |  6 +++---
 t/admin.t                | 28 ++++++++++++++++------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm
index ec80b565..eeef2f63 100644
--- a/lib/PublicInbox/Admin.pm
+++ b/lib/PublicInbox/Admin.pm
@@ -8,7 +8,7 @@ use strict;
 use parent qw(Exporter);
 use Cwd qw(abs_path);
 use POSIX ();
-our @EXPORT_OK = qw(resolve_repo_dir setup_signals);
+our @EXPORT_OK = qw(setup_signals);
 use PublicInbox::Config;
 use PublicInbox::Inbox;
 use PublicInbox::Spawn qw(popen_rd);
@@ -27,7 +27,7 @@ sub setup_signals {
 	};
 }
 
-sub resolve_repo_dir {
+sub resolve_inboxdir {
 	my ($cd, $ver) = @_;
 	my $prefix = defined $cd ? $cd : './';
 	if (-d $prefix && -f "$prefix/inbox.lock") { # v2
@@ -121,7 +121,7 @@ EOF
 		push @dirs, '.' if !@dirs && $opt->{-use_cwd};
 		foreach (@dirs) {
 			my $v;
-			my $dir = resolve_repo_dir($_, \$v);
+			my $dir = resolve_inboxdir($_, \$v);
 			if ($v < $min_ver) {
 				push @old, $dir;
 				next;
diff --git a/t/admin.t b/t/admin.t
index c25667b2..af132577 100644
--- a/t/admin.t
+++ b/t/admin.t
@@ -5,24 +5,28 @@ use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::Import;
-use_ok 'PublicInbox::Admin', qw(resolve_repo_dir);
+use_ok 'PublicInbox::Admin';
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/v1";
 my $v2_dir = "$tmpdir/v2";
 my ($res, $err, $v);
 
 PublicInbox::Import::init_bare($git_dir);
+*resolve_inboxdir = do {
+	no warnings 'once';
+	*PublicInbox::Admin::resolve_inboxdir;
+};
 
 # v1
-is(resolve_repo_dir($git_dir), $git_dir, 'top-level GIT_DIR resolved');
-is(resolve_repo_dir("$git_dir/objects"), $git_dir, 'GIT_DIR/objects resolved');
+is(resolve_inboxdir($git_dir), $git_dir, 'top-level GIT_DIR resolved');
+is(resolve_inboxdir("$git_dir/objects"), $git_dir, 'GIT_DIR/objects resolved');
 
 ok(chdir($git_dir), 'chdir GIT_DIR works');
-is(resolve_repo_dir(), $git_dir, 'resolve_repo_dir works in GIT_DIR');
+is(resolve_inboxdir(), $git_dir, 'resolve_inboxdir works in GIT_DIR');
 
 ok(chdir("$git_dir/objects"), 'chdir GIT_DIR/objects works');
-is(resolve_repo_dir(), $git_dir, 'resolve_repo_dir works in GIT_DIR');
-$res = resolve_repo_dir(undef, \$v);
+is(resolve_inboxdir(), $git_dir, 'resolve_inboxdir works in GIT_DIR');
+$res = resolve_inboxdir(undef, \$v);
 is($v, 1, 'version 1 detected');
 is($res, $git_dir, 'detects directory along with version');
 
@@ -36,13 +40,13 @@ SKIP: {
 
 	ok(chdir($no_vcs_dir), 'chdir to a non-inbox');
 	open STDERR, '>&', $null or die "redirect stderr to /dev/null: $!";
-	$res = eval { resolve_repo_dir() };
+	$res = eval { resolve_inboxdir() };
 	open STDERR, '>&', $olderr or die "restore stderr: $!";
 	is($res, undef, 'fails inside non-version-controlled dir');
 
 	ok(chdir($tmpdir), 'back to test-specific $tmpdir');
 	open STDERR, '>&', $null or die "redirect stderr to /dev/null: $!";
-	$res = eval { resolve_repo_dir($no_vcs_dir) };
+	$res = eval { resolve_inboxdir($no_vcs_dir) };
 	$err = $@;
 	open STDERR, '>&', $olderr or die "restore stderr: $!";
 	is($res, undef, 'fails on non-version-controlled dir');
@@ -66,11 +70,11 @@ SKIP: {
 	PublicInbox::V2Writable->new($ibx, 1)->idx_init;
 
 	ok(-e "$v2_dir/inbox.lock", 'exists');
-	is(resolve_repo_dir($v2_dir), $v2_dir,
-		'resolve_repo_dir works on v2_dir');
+	is(resolve_inboxdir($v2_dir), $v2_dir,
+		'resolve_inboxdir works on v2_dir');
 	ok(chdir($v2_dir), 'chdir v2_dir OK');
-	is(resolve_repo_dir(), $v2_dir, 'resolve_repo_dir works inside v2_dir');
-	$res = resolve_repo_dir(undef, \$v);
+	is(resolve_inboxdir(), $v2_dir, 'resolve_inboxdir works inside v2_dir');
+	$res = resolve_inboxdir(undef, \$v);
 	is($v, 2, 'version 2 detected');
 	is($res, $v2_dir, 'detects directory along with version');
 

  parent reply	other threads:[~2020-12-08 21:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 21:21 [PATCH 0/6] minor internal consistency things Eric Wong
2020-12-08 21:21 ` [PATCH 1/6] treewide: replace {-inbox} with {ibx} for consistency Eric Wong
2020-12-08 21:21 ` [PATCH 2/6] nntp: replace {ng} " Eric Wong
2020-12-08 21:21 ` [PATCH 3/6] rename {pi_config} fields to {pi_cfg} Eric Wong
2020-12-08 21:21 ` [PATCH 4/6] extindex: do not use current dir like -index does Eric Wong
2020-12-08 21:21 ` Eric Wong [this message]
2020-12-08 21:21 ` [PATCH 6/6] extsearchidx: ck_existing: set $OID for warning context 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=20201208212130.5832-6-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).