summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
10fad7e)
PublicInbox::Admin::config() just adds an extra layer of
indirection which we barely rely on. So get rid of this
global variable and make it easier to run tests in the
future without relying on global state.
use Cwd 'abs_path';
use base qw(Exporter);
our @EXPORT_OK = qw(resolve_repo_dir);
use Cwd 'abs_path';
use base qw(Exporter);
our @EXPORT_OK = qw(resolve_repo_dir);
-my $CFG; # all the admin stuff is a singleton
require PublicInbox::Config;
sub resolve_repo_dir {
require PublicInbox::Config;
sub resolve_repo_dir {
-sub config () { $CFG //= eval { PublicInbox::Config->new } }
-
-sub resolve_inboxes ($;$) {
- my ($argv, $opt) = @_;
+sub resolve_inboxes ($;$$) {
+ my ($argv, $opt, $cfg) = @_;
require PublicInbox::Inbox;
$opt ||= {};
require PublicInbox::Inbox;
$opt ||= {};
+ $cfg //= eval { PublicInbox::Config->new };
if ($opt->{all}) {
my $cfgfile = PublicInbox::Config::default_file();
$cfg or die "--all specified, but $cfgfile not readable\n";
if ($opt->{all}) {
my $cfgfile = PublicInbox::Config::default_file();
$cfg or die "--all specified, but $cfgfile not readable\n";
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
die "bad command-line args\n$usage\n";
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
die "bad command-line args\n$usage\n";
+my $cfg = eval { PublicInbox::Config->new };
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
unless (defined $editor) {
my $k = 'publicinbox.mailEditor';
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
unless (defined $editor) {
my $k = 'publicinbox.mailEditor';
- if (my $cfg = PublicInbox::Admin::config()) {
- $editor = $cfg->{lc($k)};
- }
+ $editor = $cfg->{lc($k)} if $cfg;
unless (defined $editor) {
warn "\`$k' not configured, trying \`git var GIT_EDITOR'\n";
chomp($editor = `git var GIT_EDITOR`);
unless (defined $editor) {
warn "\`$k' not configured, trying \`git var GIT_EDITOR'\n";
chomp($editor = `git var GIT_EDITOR`);
die "the --mid and --file options are mutually exclusive\n";
}
die "the --mid and --file options are mutually exclusive\n";
}
-my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
+my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt, $cfg);
PublicInbox::AdminEdit::check_editable(\@ibxs);
my $found = {}; # cid => [ [ibx, smsg] [, [ibx, smsg] ] ]
PublicInbox::AdminEdit::check_editable(\@ibxs);
my $found = {}; # cid => [ [ibx, smsg] [, [ibx, smsg] ] ]