7 use Config qw/%Config/;
9 use File::Spec::Functions qw/catfile path/;
10 use List::Util qw/first/;
12 use App::Rgit::Utils qw/:codes/;
15 our $VERSION = '0.03';
18 if (-t && eval { use Term::ReadKey; 1 }) {
20 my ($cmd, $conf, $repo, $status, $signal) = @_;
21 return NEXT unless $status;
22 print STDERR "[a]bort, [i]gnore, [I]gnore all, [r]etry, open [s]hell ?";
34 $key = 'a' unless defined $key;
35 my $code = $codes{$key};
36 $code = $codes{a} unless defined $code;
41 my ($cmd, $conf, $repo, $status, $signal) = @_;
42 return NEXT unless $status;
48 setpgrp 0, 0 if $Config{d_setpgrp};
50 my $cmd = first { !/^-/ } @ARGV;
51 $cmd = ' ' unless defined $cmd;
53 my $git = $ENV{GIT_EXEC_PATH};
54 unless (defined $git) {
56 my $g = catfile $_, 'git';
63 croak "Couldn't find any valid git executable" unless defined $git;
65 my $root = $ENV{GIT_DIR};
66 $root = cwd unless defined $root;
80 rgit - Recursively execute a command on all the git repositories in a directory tree.
88 rgit [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
92 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.
93 Moreover, those formats are substuted in the arguments before running the command :
99 C<^n> with the current repository name.
103 C<^g> with the relative path to the current repository.
107 C<^G> with the absolute path to the current repository.
111 C<^w> with the relative path to the current repository's working directory.
115 C<^W> with the absolute path to the current repository's working directory.
119 C<^b> with a "bareified" relative path, i.e. C<^g> if this is a bare repository, and C<^w.git> otherwise.
123 C<^B> with an absolute version of the "bareified" path.
127 C<^R> with the absolute path to the current root directory.
131 C<^^> with a bare C<^>.
135 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>.
136 For any of those, no format substitution is done.
138 You can specify which C<git> executable to use with the C<GIT_EXEC_PATH> environment variable.
142 Execute C<git gc> on all the repositories below the current directory :
146 Tag all the repositories with their name :
150 Add a remote to all repositories in "/foo/bar" to their bare counterpart in C<qux> on F<host> :
152 GIT_DIR="/foo/bar" rgit remote add host git://host/qux/^b
156 The core modules L<Carp>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions>, L<List::Util> and L<POSIX>.
162 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
164 You can contact me by mail or on C<irc.perl.org> (vincent).
168 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.
172 You can find documentation for this module with the perldoc command.
176 Tests code coverage report is available at L<http://www.profvince.com/perl/cover/rgit>.
178 =head1 COPYRIGHT & LICENSE
180 Copyright 2008 Vincent Pit, all rights reserved.
182 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.