From fb56bf2192ab2a6cfdc7bcef5330d33cc5d1ae23 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Mon, 14 Jul 2008 23:37:53 +1200 Subject: [PATCH] Fix up some problems with setting the VCS. --- lib/CIL.pm | 9 ++++----- lib/CIL/VCS/Factory.pm | 1 + lib/CIL/VCS/Null.pm | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/CIL.pm b/lib/CIL.pm index 1049f59..72676f1 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -42,6 +42,7 @@ my $defaults = { IssueDir => 'issues', # the dir to save the issues in StatusStrict => 0, # whether to complain if a status is invalid LabelStrict => 0, # whether to complain if a label is invalid + VCS => 'Null', # don't do anything for VCS hooks }; my @config_hashes = qw(StatusAllowed StatusOpen StatusClosed LabelAllowed); @@ -265,11 +266,9 @@ sub read_config_file { $self->LabelAllowed( $cfg->{LabelAllowed} ); # if we are allowed this VCS, create the hook instance - if ( exists $allowed->{vcs}{$cfg->{VCS}} ) { - $self->VCS( $cfg->{VCS} ); - my $vcs = CIL::VCS::Factory->new( $cfg->{VCS} ); - $self->vcs( $vcs ); - } + $self->VCS( $cfg->{VCS} || 'Null' ); + my $vcs = CIL::VCS::Factory->new( $cfg->{VCS} ); + $self->vcs( $vcs ); } sub register_hook { diff --git a/lib/CIL/VCS/Factory.pm b/lib/CIL/VCS/Factory.pm index 7b427e9..ec5da53 100644 --- a/lib/CIL/VCS/Factory.pm +++ b/lib/CIL/VCS/Factory.pm @@ -27,6 +27,7 @@ use Carp; use base qw( Class::Factory ); +__PACKAGE__->register_factory_type( Null => 'CIL::VCS::Null' ); __PACKAGE__->register_factory_type( Git => 'CIL::VCS::Git' ); foreach my $method_name ( qw(post_add) ) { diff --git a/lib/CIL/VCS/Null.pm b/lib/CIL/VCS/Null.pm index b062771..4cef1a4 100644 --- a/lib/CIL/VCS/Null.pm +++ b/lib/CIL/VCS/Null.pm @@ -25,9 +25,11 @@ use strict; use warnings; use Carp; +use base qw(CIL::VCS::Factory); + foreach my $method_name ( qw(post_add) ) { no strict 'refs'; - *{"${class}::$method_name"} = sub {}; + *{"CIL::VCS::Null::$method_name"} = sub {}; } ## ---------------------------------------------------------------------------- -- 2.39.5