]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - bin/rgit
Set a process group when possible
[perl/modules/rgit.git] / bin / rgit
index 6b45da539e66840042e8aae6f0214b7dda8ea73b..ca7b0f34b2bcb710e34391329a85b19335a3aea9 100755 (executable)
--- a/bin/rgit
+++ b/bin/rgit
@@ -4,13 +4,48 @@ use strict;
 use warnings;
 
 use Carp qw/croak/;
+use Config qw/%Config/;
 use Cwd qw/cwd/;
 use File::Spec::Functions qw/catfile path/;
 use List::Util qw/first/;
 
+use App::Rgit::Utils qw/:codes/;
 use App::Rgit;
 
-our $VERSION = '0.01';
+our $VERSION = '0.03';
+
+BEGIN {
+ if (-t && eval { use Term::ReadKey; 1 }) {
+  *policy = sub {
+   my ($cmd, $conf, $repo, $status, $signal) = @_;
+   return NEXT unless $status;
+   print STDERR "[a]bort, [i]gnore, [I]gnore all, [r]etry, open [s]hell ?";
+   ReadMode 4;
+   my $key = ReadKey 0;
+   ReadMode 1;
+   print STDERR "\n";
+   my %codes = (
+    'a' => LAST,
+    'i' => NEXT,
+    'I' => NEXT | SAVE,
+    'r' => REDO,
+    's' => LAST,
+   );
+   $key = 'a' unless defined $key;
+   my $code = $codes{$key};
+   $code = $codes{a} unless defined $code;
+   return $code;
+  };
+ } else {
+  *policy = sub {
+   my ($cmd, $conf, $repo, $status, $signal) = @_;
+   return NEXT unless $status;
+   return LAST;
+  };
+ }
+}
+
+setpgrp 0, 0 if $Config{d_setpgrp};
 
 my $cmd = first { !/^-/ } @ARGV;
 $cmd = ' ' unless defined $cmd;
@@ -31,10 +66,11 @@ my $root = $ENV{GIT_DIR};
 $root = cwd unless defined $root;
 
 exit App::Rgit->new(
- git  => $git,
- root => $root,
- cmd  => $cmd,
- args => \@ARGV
+ git    => $git,
+ root   => $root,
+ cmd    => $cmd,
+ args   => \@ARGV,
+ policy => \&policy,
 )->run;
 
 __END__
@@ -45,7 +81,7 @@ rgit - Recursively execute a command on all the git repositories in a directory
 
 =head1 VERSION
 
-Version 0.01
+Version 0.03
 
 =head1 SYNOPSIS
 
@@ -53,7 +89,7 @@ Version 0.01
 
 =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
@@ -84,7 +120,7 @@ C<^b> with a "bareified" relative path, i.e. C<^g> if this is a bare repository,
 
 =item *
 
-C<^B> is the absolute version of the "bareified" path.
+C<^B> with an absolute version of the "bareified" path.
 
 =item *
 
@@ -96,7 +132,7 @@ C<^^> with a bare C<^>.
 
 =back
 
-There are actually a few commands that are only executed once in the current directory : C<version>, C<help>, C<daemon> and C<init>.
+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>.
 For any of those, no format substitution is done.
 
 You can specify which C<git> executable to use with the C<GIT_EXEC_PATH> environment variable.
@@ -117,7 +153,7 @@ Add a remote to all repositories in "/foo/bar" to their bare counterpart in C<qu
 
 =head1 DEPENDENCIES
 
-The core modules L<Carp>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions> and L<List::Util>.
+The core modules L<Carp>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions>, L<List::Util> and L<POSIX>.
 
 L<Object::Tiny>.