From 68c0b1e19dd90db236a5b9dd862ab3251c0817a0 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Sat, 5 Jul 2008 15:52:40 +1200 Subject: Imported Upstream version 0.5.0 --- lib/CIL.pm | 26 ++++++++++++++++++-------- lib/CIL/Utils.pm | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/CIL.pm b/lib/CIL.pm index ee85064..9a87bf9 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -30,6 +30,7 @@ __PACKAGE__->mk_accessors(qw( IssueDir StatusStrict StatusAllowed StatusOpen StatusClosed LabelStrict LabelAllowed + VCS UserName UserEmail )); @@ -217,19 +218,26 @@ sub read_config_file { } # set some defaults if we don't have any of these - foreach my $key ( keys %$defaults ) { - $cfg->{$key} ||= $defaults->{$key}; - } + %$cfg = (%$defaults, %$cfg); # for some things, make a hash out of them foreach my $hash_name ( @config_hashes ) { - my $h = {}; - my @list = ref $cfg->{"${hash_name}List"} eq 'ARRAY' ? @{$cfg->{"${hash_name}List"}} : $cfg->{"${hash_name}List"}; - foreach my $thing ( @list ) { - $h->{$thing} = 1; + # if we have nothing in the cfg hash already, set it to empty and move on + unless ( exists $cfg->{"${hash_name}List"} ) { + $cfg->{$hash_name} = {}; + next; } + + # if we only have a single item, turn it into an array first + my $key = "${hash_name}List"; + $cfg->{$key} = [ $cfg->{$key} ] unless ref $cfg->{$key} eq 'ARRAY'; + + # loop through all the items making up the hash + my $h = {}; + $h->{$_} = 1 + for @{ $cfg->{$key} }; $cfg->{$hash_name} = $h; - undef $cfg->{"${hash_name}List"}; + undef $cfg->{$key}; } # set each config item @@ -242,6 +250,8 @@ sub read_config_file { $self->LabelStrict( $cfg->{LabelStrict} ); $self->LabelAllowed( $cfg->{LabelAllowed} ); + + $self->VCS( $cfg->{VCS} ); } ## ---------------------------------------------------------------------------- diff --git a/lib/CIL/Utils.pm b/lib/CIL/Utils.pm index e9611cf..47f7ada 100644 --- a/lib/CIL/Utils.pm +++ b/lib/CIL/Utils.pm @@ -41,7 +41,7 @@ sub parse_cil_file { my ($class, $filename, $last_field) = @_; my @lines = read_file($filename); - return unless @lines; + return {} unless @lines; return $class->parse_from_lines( $last_field, @lines ); } -- cgit v1.2.3