=head1 DESCRIPTION
-This utility recursively searches in the current directory (or in the directory given by the C<GIT_DIR> environment variable if it's set) for all git repositories, C<chdir> into each of them, and executes the specified git command.
+This utility recursively searches in the current directory (or in the directory given by the C<GIT_DIR> environment variable if it's set) for all git repositories, sort this list by the repository path, C<chdir> into each of them, and executes the specified git command.
Moreover, those formats are substuted in the arguments before running the command :
=over 4
use File::Spec::Functions qw/catdir catfile/;
use File::Temp qw/tempfile tempdir/;
-use Test::More tests => 2 + 3 * 1;
+use Test::More tests => 2 + 3 * 2;
use App::Rgit;
my $tmpdir = tempdir(CLEANUP => 1);
my $cwd = cwd;
chdir $tmpdir or die "chdir($tmpdir): $!";
-my @expected = sort { $a->[0] cmp $b->[0] } build({
+my @expected = sort { $a->[1] cmp $b->[1] } build({
x => {
a => {
_ => repo('a', 0),
'^n'
], @expected;
-for my $cmd (qw/commit/) {
+for my $cmd (qw/commit FAIL/) {
my ($fh, $filename) = tempfile(UNLINK => 1);
my $ar = App::Rgit->new(
git => abs_path('t/bin/git'),
);
isnt($ar, undef, "each $cmd has a defined object");
my $exit = $ar->run;
- is($exit, 0, "each $cmd returned 0");
- my @lines = sort split /\n/, do { local $/; <$fh> };
+ my $fail = $cmd eq 'FAIL' ? 1 : 0;
+ is($exit, $fail << 8, "each $cmd returned $fail");
+ my @lines = split /\n/, do { local $/; <$fh> };
my $res = [ map [ split /\|/, $_ ], @lines ];
- my $exp = [ map [ $cmd, @$_ ], @expected ];
+ my $exp = [ map [ $cmd, @$_ ], $fail ? $expected[0] : @expected ];
is_deeply($res, $exp, "each $cmd did the right thing");
}
# This has to work with olde perls
my $filename = shift @ARGV;
+my $cmd = shift @ARGV;
open FH, ">>$filename" or die "open($filename): $!";
-print FH join '|', @ARGV;
+print FH join '|', $cmd, @ARGV;
print FH "\n";
close FH;
+
+exit(($cmd && $cmd eq 'FAIL') ? 1 : 0);