Skip to content
Browse files

Use Config::GitLike instead of Config::INI::Reader

The config files that Git uses are *not* .ini files, they're just in
ini-like format. By using a module that can actually parse them we
won't die on e.g. config files with multi-line values escaped with
"\\n".
  • Loading branch information...
1 parent 481c9cf commit e6e0bea8c29d48c88ecbb182e03784ba01069ec6 @avar avar committed Oct 3, 2011
Showing with 9 additions and 8 deletions.
  1. +1 −1 dist.ini
  2. +4 −3 lib/Git/Megapull.pm
  3. +4 −4 lib/Git/Megapull/Source/Github.pm
View
2 dist.ini
@@ -10,5 +10,5 @@ autodie = 0
JSON = 2
LWP::UserAgent = 0
App::Cmd::Simple = 0
-Config::INI::Reader = 0
+Config::GitLike = 1.05
String::RewritePrefix = 0
View
7 lib/Git/Megapull.pm
@@ -5,7 +5,7 @@ use base 'App::Cmd::Simple';
# ABSTRACT: clone or update all repositories found elsewhere
use autodie;
-use Config::INI::Reader;
+use Config::GitLike;
use String::RewritePrefix;
=head1 OVERVIEW
@@ -61,8 +61,9 @@ sub execute {
my $source = $opt->{source};
unless ($source) {
- my $config = Config::INI::Reader->read_file("$ENV{HOME}/.gitconfig");
- $source = $config->{megapull}{source};
+ my $config = Config::GitLike->new(confname => "$ENV{HOME}/.gitconfig");
+ $config->load;
+ $source = $config->get(key => "megapull.source");
}
$source ||= $self->_default_source;
View
8 lib/Git/Megapull/Source/Github.pm
@@ -5,7 +5,7 @@ use base 'Git::Megapull::Source';
# ABSTRACT: clone/update all your repositories from github.com
use LWP::UserAgent;
-use Config::INI::Reader;
+use Config::GitLike;
use JSON 2 ();
=head1 OVERVIEW
@@ -33,9 +33,9 @@ hashref with repo names as keys and repo URIs as values.
sub repo_uris {
my $config_file = "$ENV{HOME}/.gitconfig";
- my $config = Config::INI::Reader->read_file($config_file);
- my $login = $config->{github}{login} || die "No github.login found in `$config_file'\n";
- my $token = $config->{github}{token} || die "No github.token found in `$config_file'\n";
+ my $config = Config::GitLike->new(confname => $config_file);
+ my $login = $config->get(key => "github.login") || die "No github.login found in `$config_file'\n";
+ my $token = $config->get(key => "github.token") || die "No github.token found in `$config_file'\n";
my $json = _get_json("http://github.com/api/v1/json/$login?login=$login&token=$token");

0 comments on commit e6e0bea

Please sign in to comment.
Something went wrong with that request. Please try again.