X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=lib%2FApp%2FRgit%2FCommand%2FEach.pm;h=d111f3243423b05046ffcebb88f76332a3fee90c;hp=2981904f8095b11963d54c258fec1b906bbbfa3f;hb=3c8fbdcb1480e5d245448b8fa2f99fa36c489cf2;hpb=19bee8f647bfe6c94c5cb3cf6a60d7a43cbca222 diff --git a/lib/App/Rgit/Command/Each.pm b/lib/App/Rgit/Command/Each.pm index 2981904..d111f32 100644 --- a/lib/App/Rgit/Command/Each.pm +++ b/lib/App/Rgit/Command/Each.pm @@ -5,17 +5,20 @@ use warnings; use base qw/App::Rgit::Command/; +use App::Rgit::Guard; +use App::Rgit::Utils qw/:codes/; + =head1 NAME App::Rgit::Command::Each - Class for commands to execute for each repository. =head1 VERSION -Version 0.01 +Version 0.06 =cut -our $VERSION = '0.01'; +our $VERSION = '0.06'; =head1 DESCRIPTION @@ -35,20 +38,39 @@ It implements : sub run { my $self = shift; + my $conf = shift; + my $status = 0; - for (@{$self->repos}) { + my $code; + + my $repos = 0; + my $guard = App::Rgit::Guard->new(sub { $conf->cwd_repo->chdir if $repos }); + + for (@{$conf->repos}) { $_->chdir or next; - $status = $_->run($_[0], @{$self->args}); - last if $status; + ++$repos; + + ($status, my $signal) = $_->run($conf, @{$self->args}); + + $code = $self->report($conf, $_, $status, $signal) unless defined $code; + + last if $code & LAST; + if ($code & REDO) { + undef $code; # Don't save it, that would be very dumb + redo; + } + undef $code unless $code & SAVE; } - $self->cwd_as_repo->chdir; - return $status; + + return wantarray ? ($status, $code) : $status; } =head1 SEE ALSO L. +L. + =head1 AUTHOR Vincent Pit, C<< >>, L. @@ -67,7 +89,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2008 Vincent Pit, all rights reserved. +Copyright 2008,2009,2010 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.