7 use Config qw/%Config/;
9 use File::Spec::Functions qw/catfile path/;
11 use App::Rgit::Utils qw/:codes/;
25 : ( /^-([IKV]+)$/ ? do { $opts{$_} = 1 for split //, $1; () }
26 : do { $cmd = $_ unless /^-/; $_ } )
28 warn "rgit $VERSION\n" if $opts{V};
29 $cmd = ' ' unless defined $cmd;
34 if (eval "require Term::ReadKey; 1") {
35 Term::ReadKey->import;
37 my ($cmd, $conf, $repo, $status, $signal) = @_;
38 return NEXT unless $status;
39 print STDERR 'The command failed for ' . $repo->work . "\n";
40 print STDERR "[a]bort, [i]gnore, [I]gnore all, [r]etry ?";
51 $key = 'a' unless defined $key;
52 my $code = $codes{$key};
53 $code = $codes{a} unless defined $code;
57 warn "You have to install Term::ReadKey to use the interactive mode.\n";
60 *policy = sub { NEXT } if $opts{K} and not defined *policy{CODE};
62 my ($cmd, $conf, $repo, $status, $signal) = @_;
63 return NEXT unless $status;
65 } unless defined *policy{CODE};
68 setpgrp 0, 0 if $Config{d_setpgrp};
70 my $git = $ENV{GIT_EXEC_PATH};
71 unless (defined $git) {
73 my $g = catfile $_, 'git';
80 croak "Couldn't find any valid git executable" unless defined $git;
82 my $root = $ENV{GIT_DIR};
83 $root = cwd unless defined $root;
97 rgit - Recursively execute a command on all the git repositories in a directory tree.
105 rgit [-K|-V|-I] [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
109 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.
110 Moreover, those formats are substuted in the arguments before running the command :
116 C<^n> with the current repository name.
120 C<^g> with the relative path to the current repository.
124 C<^G> with the absolute path to the current repository.
128 C<^w> with the relative path to the current repository's working directory.
132 C<^W> with the absolute path to the current repository's working directory.
136 C<^b> with a "bareified" relative path, i.e. C<^g> if this is a bare repository, and C<^w.git> otherwise.
140 C<^B> with an absolute version of the "bareified" path.
144 C<^R> with the absolute path to the current root directory.
148 C<^^> with a bare C<^>.
152 There are actually a few commands that are only executed once in the current directory : C<daemon>, C<gui>, C<help>, C<init> and C<version>.
153 For any of those, no format substitution is done.
155 You can specify which C<git> executable to use with the C<GIT_EXEC_PATH> environment variable.
157 =head1 COMMAND LINE SWITCHES
159 C<rgit> takes its options as the capital switches that comes before the git command.
160 It's possible to bundle them together.
161 They are removed from the argument list before calling C<git>.
169 Keep processing on error.
170 The default policy is to stop whenever an error occured.
176 Enables interactive mode when the standard input is a tty.
177 Requires L<Term::ReadKey> to be installed.
178 This lets you choose interactively what to do when one of the commands returns a non-zero status.
190 Execute C<git gc> on all the repositories below the current directory :
194 Tag all the repositories with their name :
198 Add a remote to all repositories in "/foo/bar" to their bare counterpart in C<qux> on F<host> :
200 GIT_DIR="/foo/bar" rgit remote add host git://host/qux/^b
204 The core modules L<Carp>, C<Config>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions> and L<POSIX>.
210 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
212 You can contact me by mail or on C<irc.perl.org> (vincent).
216 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.
220 You can find documentation for this module with the perldoc command.
224 Tests code coverage report is available at L<http://www.profvince.com/perl/cover/rgit>.
226 =head1 COPYRIGHT & LICENSE
228 Copyright 2008 Vincent Pit, all rights reserved.
230 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.