8 use File::Spec::Functions qw/catfile path/;
9 use List::Util qw/first/;
11 use App::Rgit::Utils qw/:codes/;
14 our $VERSION = '0.03';
17 if (-t && eval { use Term::ReadKey; 1 }) {
19 my ($cmd, $conf, $repo, $status) = @_;
20 return NEXT unless $status;
21 print STDERR "git returned $status\n";
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) = @_;
42 return NEXT unless $status;
43 print STDERR "git returned $status, aborting\n";
49 my $cmd = first { !/^-/ } @ARGV;
50 $cmd = ' ' unless defined $cmd;
52 my $git = $ENV{GIT_EXEC_PATH};
53 unless (defined $git) {
55 my $g = catfile $_, 'git';
62 croak "Couldn't find any valid git executable" unless defined $git;
64 my $root = $ENV{GIT_DIR};
65 $root = cwd unless defined $root;
79 rgit - Recursively execute a command on all the git repositories in a directory tree.
87 rgit [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
91 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.
92 Moreover, those formats are substuted in the arguments before running the command :
98 C<^n> with the current repository name.
102 C<^g> with the relative path to the current repository.
106 C<^G> with the absolute path to the current repository.
110 C<^w> with the relative path to the current repository's working directory.
114 C<^W> with the absolute path to the current repository's working directory.
118 C<^b> with a "bareified" relative path, i.e. C<^g> if this is a bare repository, and C<^w.git> otherwise.
122 C<^B> with an absolute version of the "bareified" path.
126 C<^R> with the absolute path to the current root directory.
130 C<^^> with a bare C<^>.
134 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>.
135 For any of those, no format substitution is done.
137 You can specify which C<git> executable to use with the C<GIT_EXEC_PATH> environment variable.
141 Execute C<git gc> on all the repositories below the current directory :
145 Tag all the repositories with their name :
149 Add a remote to all repositories in "/foo/bar" to their bare counterpart in C<qux> on F<host> :
151 GIT_DIR="/foo/bar" rgit remote add host git://host/qux/^b
155 The core modules L<Carp>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions> and L<List::Util>.
161 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
163 You can contact me by mail or on C<irc.perl.org> (vincent).
167 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.
171 You can find documentation for this module with the perldoc command.
175 Tests code coverage report is available at L<http://www.profvince.com/perl/cover/rgit>.
177 =head1 COPYRIGHT & LICENSE
179 Copyright 2008 Vincent Pit, all rights reserved.
181 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.