Summary: Make cil read from a ~/.cilrc file for local settings
-Status: New
+Status: Finished
CreatedBy: Andrew Chilton <andychilton@gmail.com>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
Label: Milestone-v0.06
Inserted: 2010-01-23T11:22:40
-Updated: 2010-01-23T11:24:57
+Updated: 2010-01-23T11:46:20
To do things like auto-assigning to yourself, and to override CreatedBy fields,
cil should read from a ~/.cilrc file, rather than trying to figure it out from
use warnings;
use Carp qw(croak confess);
use File::Glob qw(:glob);
+use File::HomeDir;
+use Git;
use vars qw( $VERSION );
$VERSION = '0.5.1';
-use Module::Pluggable
+use Module::Pluggable
sub_name => 'commands',
search_path => [ 'CIL::Command' ],
require => 1;
LabelStrict LabelAllowed
DefaultNewStatus
VCS
+ UserName UserEmail
+ AutoAssignSelf
vcs hook
vcs_revision
));
my @config_hashes = qw(StatusAllowed StatusOpen StatusClosed LabelAllowed);
my $defaults_user = {
- UserName => 'Name',
- UserEmail => 'me@example.com',
+ UserName => eval { Git->repository->config( 'user.name' ) } || 'UserName',
+ UserEmail => eval { Git->repository->config( 'user.email' ) } || 'username@example.org',
+ AutoAssignSelf => 0,
};
my $allowed = {
sub read_config_user {
my ($self) = @_;
- my $filename = "$ENV{HOME}/.cilrc";
+ my $filename = File::HomeDir->my_home() . '/.cilrc';
my $cfg;
if ( -f $filename ) {
}
# set each config to be either the user defined one or the default
- foreach ( qw() ) { # nothing yet
+ foreach ( qw(UserName UserEmail AutoAssignSelf) ) {
$self->$_( $cfg->{$_} || $defaults_user->{$_} );
}
}
}
}
-## ----------------------------------------------------------------------------
-# simple delegates to elsewhere
-
-sub UserName {
- my ($self) = @_;
- return $self->vcs->UserName
-}
-
-sub UserEmail {
- my ($self) = @_;
- return $self->vcs->UserEmail
-}
-
## ----------------------------------------------------------------------------
1;
## ----------------------------------------------------------------------------