From: Vincent Pit Date: Mon, 6 Oct 2008 14:51:38 +0000 (+0200) Subject: Move the fake root repository from the Command to the Config object X-Git-Tag: v0.03~10 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=34eec9dcea44c01535ee6ab4593d98a724ce7e06;p=perl%2Fmodules%2Frgit.git Move the fake root repository from the Command to the Config object --- diff --git a/lib/App/Rgit/Command.pm b/lib/App/Rgit/Command.pm index a73c9b4..aa709c1 100644 --- a/lib/App/Rgit/Command.pm +++ b/lib/App/Rgit/Command.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; -use Object::Tiny qw/cmd cwd_as_repo args/; +use Object::Tiny qw/cmd args/; use App::Rgit::Utils qw/validate/; use App::Rgit::Repository; @@ -51,12 +51,9 @@ sub new { unless $class->isa($action); } eval "require $action; 1" or croak "Couldn't load $action: $@"; - my $r = App::Rgit::Repository->new(fake => 1); - return unless defined $r; $class->SUPER::new( - cmd => $cmd, - args => $args{args} || [ ], - cwd_as_repo => $r, + cmd => $cmd, + args => $args{args} || [ ], ); } @@ -83,8 +80,6 @@ sub action { =head2 C -=head2 C - =head2 C Accessors. diff --git a/lib/App/Rgit/Command/Each.pm b/lib/App/Rgit/Command/Each.pm index 2825ef6..c313dc8 100644 --- a/lib/App/Rgit/Command/Each.pm +++ b/lib/App/Rgit/Command/Each.pm @@ -42,7 +42,7 @@ sub run { $status = $_->run($conf, @{$self->args}); last if $status; } - $self->cwd_as_repo->chdir; + $conf->root_repo->chdir; return $status; } diff --git a/lib/App/Rgit/Command/Once.pm b/lib/App/Rgit/Command/Once.pm index 93d1bb9..24530a6 100644 --- a/lib/App/Rgit/Command/Once.pm +++ b/lib/App/Rgit/Command/Once.pm @@ -35,7 +35,7 @@ It implements : sub run { my ($self, $conf) = @_; - $self->cwd_as_repo->run($conf, @{$self->args}); + $conf->root_repo->run($conf, @{$self->args}); } =head1 SEE ALSO diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index 846006e..8044f57 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -7,8 +7,9 @@ use Carp qw/croak/; use Cwd qw/abs_path/; use File::Spec::Functions qw/file_name_is_absolute/; -use Object::Tiny qw/root git/; +use Object::Tiny qw/root root_repo git/; +use App::Rgit::Repository; use App::Rgit::Utils qw/validate/; =head1 NAME @@ -45,14 +46,19 @@ sub new { return unless defined $args{git} and -x $args{git}; my $conf = 'App::Rgit::Config::Default'; eval "require $conf; 1" or croak "Couldn't load $conf: $@"; + my $r = App::Rgit::Repository->new(fake => 1); + return unless defined $r; $conf->SUPER::new( - root => $args{root}, - git => $args{git}, + root => $args{root}, + root_repo => $r, + git => $args{git}, ); } =head2 C +=head2 C + =head2 C =head2 C