From 928cd33fbcf6efb9c476d1aa26d060883fcae4b8 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Sun, 24 Jan 2010 01:27:29 +1300 Subject: [PATCH] Fix reading of the ~/.cilrc (esp. in the absence of any Git information --- lib/CIL.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/CIL.pm b/lib/CIL.pm index e5065e2..b73de91 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -234,12 +234,20 @@ sub read_config_user { my $filename = File::HomeDir->my_home() . '/.cilrc'; + # firstly, set the default config my $cfg; + %$cfg = %$defaults_user; + + # then read the ~/.cilrc file if ( -f $filename ) { $cfg = CIL::Utils->parse_cil_file( $filename ); } - # set each config to be either the user defined one or the default + # for some settings, see if we can get it from Git + $cfg->{UserName} = eval { Git->repository->config( 'user.name' ) } || $cfg->{UserName}; + $cfg->{UserEmail} = eval { Git->repository->config( 'user.email' ) } || $cfg->{UserEmail}; + + # save them all internally foreach ( qw(UserName UserEmail AutoAssignSelf) ) { $self->$_( $cfg->{$_} || $defaults_user->{$_} ); } -- 2.39.5