From 8643dc886319e94eadede251f6957ba65c485b5c Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Sun, 7 Sep 2008 22:38:17 +1200 Subject: [PATCH] Get UserName and UserEmail from Git itself --- bin/cil | 7 ------- lib/CIL.pm | 16 ++++++++++++++-- lib/CIL/VCS/Git.pm | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/cil b/bin/cil index 00e706a..648af93 100755 --- 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 diff --git a/lib/CIL.pm b/lib/CIL.pm index 3391094..4c167a7 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -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; ## ---------------------------------------------------------------------------- diff --git a/lib/CIL/VCS/Git.pm b/lib/CIL/VCS/Git.pm index a256b55..b41d545 100644 --- a/lib/CIL/VCS/Git.pm +++ b/lib/CIL/VCS/Git.pm @@ -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' ); } -- 2.39.5