]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - lib/App/Rgit/Command/Each.pm
Allow user-defined policies. Enable interactive failure handling when Term::ReadKey...
[perl/modules/rgit.git] / lib / App / Rgit / Command / Each.pm
index a42ddb886d988b06ed55fc2ce0e73e6261a93cd7..7996f3d1795f515ad3f9057368f1128c95f06f73 100644 (file)
@@ -5,6 +5,8 @@ use warnings;
 
 use base qw/App::Rgit::Command/;
 
+use App::Rgit::Utils qw/:codes/;
+
 =head1 NAME
 
 App::Rgit::Command::Each - Class for commands to execute for each repository.
@@ -37,13 +39,20 @@ sub run {
  my $self = shift;
  my $conf = shift;
  my $status = 0;
+ my $code;
  for (@{$conf->repos}) {
   $_->chdir or next;
   $status = $_->run($conf, @{$self->args});
-  last if $status;
+  $code = $self->report($conf, $_, $status) unless defined $code;
+  if ($code & REDO) {
+   undef $code; # Don't save it, that would be very dumb
+   redo;
+  }
+  last if $code & LAST;
+  undef $code unless $code & SAVE;
  }
  $conf->cwd_repo->chdir;
- return $status;
+ return wantarray ? ($status, $code) : $status;
 }
 
 =head1 SEE ALSO