summaryrefslogtreecommitdiff
path: root/libpiny/lib/Piny/User.pm
diff options
context:
space:
mode:
Diffstat (limited to 'libpiny/lib/Piny/User.pm')
-rw-r--r--libpiny/lib/Piny/User.pm33
1 files changed, 32 insertions, 1 deletions
diff --git a/libpiny/lib/Piny/User.pm b/libpiny/lib/Piny/User.pm
index baae258..f742f87 100644
--- a/libpiny/lib/Piny/User.pm
+++ b/libpiny/lib/Piny/User.pm
@@ -10,6 +10,7 @@ use Moose;
use Moose::Util::TypeConstraints;
use MooseX::StrictConstructor;
+use Piny::Config;
use Piny::Email;
use Piny::Group;
@@ -49,6 +50,20 @@ has 'password_hash' =>
, init_arg => undef
);
+has 'home' =>
+ ( is => 'ro'
+ , isa => 'Path'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'config' =>
+ ( is => 'ro'
+ , isa => 'Piny::Config'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
has 'email' =>
( is => 'ro'
, isa => 'Piny::Email'
@@ -180,10 +195,26 @@ sub _build_password_hash {
return $s->pwent( )->[1];
};
+sub _build_home {
+ my ( $s ) = @_;
+
+ return $s->pwent( )->[7];
+};
+
+sub _build_config {
+ my ( $s ) = @_;
+
+ return Piny::Config->new( confpath => $s->home . "/.gitconfig" );
+};
+
sub _build_email {
my ( $s ) = @_;
- return Piny::Email->new( address => $s->pwent( )->[6] );
+ if ( not defined $s->config->user_email ) {
+ die "You must provide a user.email attribute in your .gitconfig!\nPlease run pinyconfig --user user.email your\@email.com";
+ };
+
+ return Piny::Email->new( address => $s->config->user_email );
};
sub _build_groups {