diff options
author | Eric Wong <e@80x24.org> | 2021-04-19 08:52:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-19 20:15:58 +0000 |
commit | ab42b22acfd9670df0b61f514b4fb89fe7754846 (patch) | |
tree | 003a53391cd10dc7d09a350645cfc4703eb33d43 /lib/PublicInbox/Config.pm | |
parent | cb0bfb6843650025faed942bfd08338fdaf17b3d (diff) | |
download | public-inbox-ab42b22acfd9670df0b61f514b4fb89fe7754846.tar.gz |
I don't know if it's worth it to sub (or super)class PublicInbox::Config into something more generic for lei, but this change simplifies a good chunk of lei code that reuses the public-inbox config parsing.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r-- | lib/PublicInbox/Config.pm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 603dad98..016f50ec 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -24,11 +24,11 @@ sub new { if (ref($file) eq 'SCALAR') { # used by some tests open my $fh, '<', $file or die; # PerlIO::scalar $self = config_fh_parse($fh, "\n", '='); + bless $self, $class; } else { - $self = git_config_dump($file); + $self = git_config_dump($class, $file); $self->{'-f'} = $file; } - bless $self, $class; # caches $self->{-by_addr} = {}; $self->{-by_list_id} = {}; @@ -158,13 +158,13 @@ sub config_fh_parse ($$$) { } sub git_config_dump { - my ($file) = @_; - return {} unless -e $file; + my ($class, $file) = @_; + return bless {}, $class unless -e $file; my $cmd = [ qw(git config -z -l --includes), "--file=$file" ]; my $fh = popen_rd($cmd); my $rv = config_fh_parse($fh, "\0", "\n"); close $fh or die "failed to close (@$cmd) pipe: $?"; - $rv; + bless $rv, $class; } sub valid_foo_name ($;$) { |