]> git.mjollnir.org Git - cil.git/commitdiff
Get UserName and UserEmail from Git itself
authorAndrew Chilton <andychilton@gmail.com>
Sun, 7 Sep 2008 10:38:17 +0000 (22:38 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Sun, 7 Sep 2008 10:38:17 +0000 (22:38 +1200)
bin/cil
lib/CIL.pm
lib/CIL/VCS/Git.pm

diff --git a/bin/cil b/bin/cil
index 00e706ad09f191313f32ce8a5256d57b9510effb..648af93203fa869ca705e5e13e283d403542b0da 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -143,17 +143,12 @@ sub cmd_init {
         fatal("Couldn't create '$issues_dir' directory: $!");
     }
 
-    my $username = "unknown";
-    my $user_email;
-
     # are we in a Git repository?
     my $VCSconfig = '';
     if ( -d '.git' ) {
         msg( 'git repository detected, setting VCS accordingly' );
         $VCSconfig = 'VCS: git';
         my $vcs = CIL::VCS::Factory->new( 'Git' );
-        $username = $vcs->username     if $vcs->username;
-        $user_email = $vcs->user_email if $vcs->user_email;
     }
 
     # create a .cil file here also
@@ -167,8 +162,6 @@ sub cmd_init {
         # write a default .cil file
         write_file($config, <<"CONFIG");
 $VCSconfig
-UserName: $username
-UserEmail: $user_email
 StatusStrict: 1
 StatusAllowedList: New
 StatusAllowedList: InProgress
index 33910946a7fb010af799593865ed136c513e72f0..4c167a7f53e4d9fec85c8e36ecf652025299f7eb 100644 (file)
@@ -37,7 +37,6 @@ __PACKAGE__->mk_accessors(qw(
     StatusStrict StatusAllowed StatusOpen StatusClosed
     LabelStrict LabelAllowed
     VCS
-    UserName UserEmail
     vcs hook
     vcs_revision
 ));
@@ -221,7 +220,7 @@ sub read_config_user {
     }
 
     # set each config to be either the user defined one or the default
-    foreach ( qw(UserName UserEmail) ) {
+    foreach ( qw() ) { # nothing yet
         $self->$_( $cfg->{$_} || $defaults_user->{$_} );
     }
 }
@@ -362,6 +361,19 @@ sub save {
     }
 }
 
+## ----------------------------------------------------------------------------
+# simple delegates to elsewhere
+
+sub UserName {
+    my ($self) = @_;
+    return $self->vcs->UserName
+}
+
+sub UserEmail {
+    my ($self) = @_;
+    return $self->vcs->UserEmail
+}
+
 ## ----------------------------------------------------------------------------
 1;
 ## ----------------------------------------------------------------------------
index a256b55a4a54a4e532287378bad44baada8a69c5..b41d545db9484154bed43a6b0a740820b2fa8241 100644 (file)
@@ -85,11 +85,11 @@ sub get_fh {
     $self->git->command_output_pipe("cat-file", "blob", "$rev:$path");
 }
 
-sub username {
+sub UserName {
     return $_[0]->git->config( 'user.name' );
 }
 
-sub user_email {
+sub UserEmail {
     return $_[0]->git->config( 'user.email' );
 }