]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Config.pm
imap: start doing iterative config reloading
[public-inbox.git] / lib / PublicInbox / Config.pm
index 1ba1225e9085a8305268c2d004ac45f120a94ec3..c18c9c75b4ffee3a1fb865ca04d8ce6eda01d330 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Used throughout the project for reading configuration
@@ -99,6 +99,21 @@ sub each_inbox {
        }
 }
 
+sub iterate_start {
+       my ($self, $cb, $arg) = @_;
+       my $i = 0;
+       $self->{-iter} = [ \$i, $cb, $arg ];
+}
+
+# for PublicInbox::DS::next_tick
+sub event_step {
+       my ($self) = @_;
+       my ($i, $cb, $arg) = @{$self->{-iter}};
+       my $section = $self->{-section_order}->[$$i++];
+       delete($self->{-iter}) unless defined($section);
+       $cb->($self, $section, $arg);
+}
+
 sub lookup_newsgroup {
        my ($self, $ng) = @_;
        _lookup_fill($self, '-by_newsgroup', lc($ng));
@@ -156,7 +171,7 @@ sub config_fh_parse ($$$) {
 sub git_config_dump {
        my ($file) = @_;
        return {} unless -e $file;
-       my @cmd = (qw/git config -z -l/, "--file=$file");
+       my @cmd = (qw/git config -z -l --includes/, "--file=$file");
        my $cmd = join(' ', @cmd);
        my $fh = popen_rd(\@cmd);
        my $rv = config_fh_parse($fh, "\0", "\n");
@@ -190,6 +205,9 @@ sub cgit_repo_merge ($$$) {
                return unless -e "$path/$se";
        }
        return if -e "$path/noweb";
+       # this comes from the cgit config, and AFAIK cgit only allows
+       # repos to have one URL, but that's just the PATH_INFO component,
+       # not the Host: portion
        # $repo = { url => 'foo.git', dir => '/path/to/foo.git' }
        my $rel = $repo->{url};
        unless (defined $rel) {
@@ -207,7 +225,7 @@ sub cgit_repo_merge ($$$) {
                        $rel =~ s!/?\.git\z!!;
        }
        $self->{"coderepo.$rel.dir"} //= $path;
-       $self->{"coderepo.$rel.cgiturl"} //= $rel;
+       $self->{"coderepo.$rel.cgiturl"} //= _array($rel);
 }
 
 sub is_git_dir ($) {
@@ -332,8 +350,9 @@ sub _fill_code_repo {
                                _array($self->{lc("$pfx.${t}UrlFormat")});
        }
 
-       if (my $cgits = $self->{lc("$pfx.cgitUrl")}) {
+       if (defined(my $cgits = $self->{"$pfx.cgiturl"})) {
                $git->{cgit_url} = $cgits = _array($cgits);
+               $self->{"$pfx.cgiturl"} = $cgits;
 
                # cgit supports "/blob/?id=%s", but it's only a plain-text
                # display and requires an unabbreviated id=
@@ -363,7 +382,7 @@ sub _fill {
        my $ibx = {};
 
        foreach my $k (qw(inboxdir filter newsgroup
-                       watch watchheader httpbackendmax
+                       watch httpbackendmax
                        replyto feedmax nntpserver indexlevel)) {
                my $v = $self->{"$pfx.$k"};
                $ibx->{$k} = $v if defined $v;
@@ -384,7 +403,7 @@ sub _fill {
        # TODO: more arrays, we should support multi-value for
        # more things to encourage decentralization
        foreach my $k (qw(address altid nntpmirror coderepo hide listid url
-                       infourl)) {
+                       infourl watchheader)) {
                if (defined(my $v = $self->{"$pfx.$k"})) {
                        $ibx->{$k} = _array($v);
                }