]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Config.pm
www_stream: fix search for new.html endpoint
[public-inbox.git] / lib / PublicInbox / Config.pm
index a8c5105e636b50a2866860d686d7e4bb1eab16da..ddb4f6b1e95fe2af6a326c45d5025c64549b2918 100644 (file)
@@ -7,7 +7,6 @@ use strict;
 use warnings;
 require PublicInbox::Inbox;
 use PublicInbox::Spawn qw(popen_rd);
-use File::Path::Expand qw/expand_filename/;
 
 # returns key-value pairs of config directives in a hash
 # if keys may be multi-value, the value is an array ref containing all values
@@ -82,7 +81,7 @@ sub get {
        $self->{"publicinbox.$inbox.$key"};
 }
 
-sub config_dir { $ENV{PI_DIR} || expand_filename('~/.public-inbox') }
+sub config_dir { $ENV{PI_DIR} || "$ENV{HOME}/.public-inbox" }
 
 sub default_file {
        my $f = $ENV{PI_CONFIG};
@@ -95,7 +94,7 @@ sub git_config_dump {
        my ($in, $out);
        my @cmd = (qw/git config/, "--file=$file", '-l');
        my $cmd = join(' ', @cmd);
-       my $fh = popen_rd(\@cmd);
+       my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n";
        my %rv;
        local $/ = "\n";
        foreach my $line (<$fh>) {
@@ -121,7 +120,8 @@ sub _fill {
        my ($self, $pfx) = @_;
        my $rv = {};
 
-       foreach my $k (qw(mainrepo address filter url newsgroup)) {
+       foreach my $k (qw(mainrepo address filter url newsgroup
+                       watch watchheader)) {
                my $v = $self->{"$pfx.$k"};
                $rv->{$k} = $v if defined $v;
        }
@@ -129,10 +129,8 @@ sub _fill {
        my $name = $pfx;
        $name =~ s/\Apublicinbox\.//;
        $rv->{name} = $name;
-       my $v = $rv->{address} ||= 'public-inbox@example.com';
-       my $p = $rv->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
-       $rv->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
        $rv = PublicInbox::Inbox->new($rv);
+       my $v = $rv->{address};
        if (ref($v) eq 'ARRAY') {
                $self->{-by_addr}->{lc($_)} = $rv foreach @$v;
        } else {