]> git.vpit.fr Git - perl/modules/rgit.git/blob - lib/App/Rgit/Command/Each.pm
Make sure we chdir to the original directory at the end of App::Rgit::Command::Each...
[perl/modules/rgit.git] / lib / App / Rgit / Command / Each.pm
1 package App::Rgit::Command::Each;
2
3 use strict;
4 use warnings;
5
6 use base qw/App::Rgit::Command/;
7
8 use App::Rgit::Guard;
9 use App::Rgit::Utils qw/:codes/;
10
11 =head1 NAME
12
13 App::Rgit::Command::Each - Class for commands to execute for each repository.
14
15 =head1 VERSION
16
17 Version 0.06
18
19 =cut
20
21 our $VERSION = '0.06';
22
23 =head1 DESCRIPTION
24
25 Class for commands to execute for each repository.
26
27 This is an internal class to L<rgit>.
28
29 =head1 METHODS
30
31 This class inherits from L<App::Rgit::Command>.
32
33 It implements :
34
35 =head2 C<run>
36
37 =cut
38
39 sub run {
40  my $self = shift;
41  my $conf = shift;
42
43  my $status = 0;
44  my $code;
45
46  my $repos = 0;
47  my $guard = App::Rgit::Guard->new(sub { $conf->cwd_repo->chdir if $repos });
48
49  for (@{$conf->repos}) {
50   $_->chdir or next;
51   ++$repos;
52
53   ($status, my $signal) = $_->run($conf, @{$self->args});
54
55   $code = $self->report($conf, $_, $status, $signal) unless defined $code;
56
57   last if $code & LAST;
58   if ($code & REDO) {
59    undef $code; # Don't save it, that would be very dumb
60    redo;
61   }
62   undef $code unless $code & SAVE;
63  }
64
65  return wantarray ? ($status, $code) : $status;
66 }
67
68 =head1 SEE ALSO
69
70 L<rgit>.
71
72 L<App::Rgit::Command>.
73
74 =head1 AUTHOR
75
76 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
77
78 You can contact me by mail or on C<irc.perl.org> (vincent).
79
80 =head1 BUGS
81
82 Please report any bugs or feature requests to C<bug-rgit at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=rgit>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
83
84 =head1 SUPPORT
85
86 You can find documentation for this module with the perldoc command.
87
88     perldoc App::Rgit::Command::Each
89
90 =head1 COPYRIGHT & LICENSE
91
92 Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
93
94 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
95
96 =cut
97
98 1; # End of App::Rgit::Command::Each