Skip to content

Commit dcd28e6

Browse files
committed
Add config support
1 parent 986f890 commit dcd28e6

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ resources repository => 'git://github.com/bobtfish/git-pureperl.git';
1414
requires 'Archive::Extract' => '0';
1515
requires 'Compress::Raw::Zlib' => '0';
1616
requires 'Compress::Zlib' => '0';
17+
requires 'Config::GitLike' => '0';
1718
requires 'Data::Stream::Bulk' => '0';
1819
requires 'DateTime' => '0';
1920
requires 'Digest::SHA1' => '0';

lib/Git/PurePerl.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use DateTime;
1010
use Digest::SHA1;
1111
use File::Find::Rule;
1212
use Git::PurePerl::Actor;
13+
use Git::PurePerl::Config;
1314
use Git::PurePerl::DirectoryEntry;
1415
use Git::PurePerl::Loose;
1516
use Git::PurePerl::Object;
@@ -76,6 +77,16 @@ has 'description' => (
7677
}
7778
);
7879

80+
has 'config' => (
81+
is => 'ro',
82+
isa => 'Git::PurePerl::Config',
83+
lazy => 1,
84+
default => sub {
85+
my $self = shift;
86+
Git::PurePerl::Config->new(git => $self);
87+
}
88+
);
89+
7990
__PACKAGE__->meta->make_immutable;
8091

8192
sub BUILDARGS {

lib/Git/PurePerl/Config.pm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package Git::PurePerl::Config;
2+
use Moose;
3+
use MooseX::StrictConstructor;
4+
use Moose::Util::TypeConstraints;
5+
6+
extends 'Config::GitLike';
7+
8+
has '+confname' => ( default => "gitconfig" );
9+
has 'git' => ( is => 'ro', isa => 'Git::PurePerl', required => 1 );
10+
11+
override dir_file => sub {
12+
my $self = shift;
13+
return $self->git->gitdir->file("config");
14+
};
15+
16+
1;

t/simple.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!perl
22
use strict;
33
use warnings;
4-
use Test::More tests => 198;
4+
use Test::More tests => 201;
55
use Git::PurePerl;
66
use Path::Class;
77

@@ -102,6 +102,8 @@ hello world, again
102102
is( $git->all_sha1s->all, 9 );
103103
is( $git->all_objects->all, 9 );
104104

105+
is( $git->config->get(key => 'user.name'), 'Your Name Comes Here' );
106+
105107
$checkout_directory->rmtree;
106108
$checkout_directory->mkpath;
107109
$git->checkout($checkout_directory);

0 commit comments

Comments
 (0)