]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - lib/App/Rgit/Repository.pm
Make sure the POD headings are linkable
[perl/modules/rgit.git] / lib / App / Rgit / Repository.pm
index a9215764fe68702825c5fa4e50f3013c4f49f6fa..f1dc149a628e2d635260631a82a9ef25a175c526 100644 (file)
@@ -3,15 +3,23 @@ package App::Rgit::Repository;
 use strict;
 use warnings;
 
-use Cwd        (); # cwd, abs_path
+use Cwd        (); # cwd
 use File::Spec (); # canonpath, catdir, splitdir, abs2rel
-use POSIX      qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/;
+use POSIX      (); # WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT
+
+use App::Rgit::Utils (); # abs_path
+
+my ($WIFEXITED, $WEXITSTATUS, $WIFSIGNALED, $WTERMSIG);
 
 BEGIN {
- no warnings 'redefine';
- *WIFEXITED   = sub { 1 }             unless eval { WIFEXITED(0);   1 };
- *WEXITSTATUS = sub { shift() >> 8 }  unless eval { WEXITSTATUS(0); 1 };
- *WIFSIGNALED = sub { shift() & 127 } unless eval { WIFSIGNALED(0); 1 };
+ $WIFEXITED   = eval { POSIX::WIFEXITED(0);   1 } ? \&POSIX::WIFEXITED
+                                                  : sub { 1 };
+ $WEXITSTATUS = eval { POSIX::WEXITSTATUS(0); 1 } ? \&POSIX::WEXITSTATUS
+                                                  : sub { shift() >> 8 };
+ $WIFSIGNALED = eval { POSIX::WIFSIGNALED(0); 1 } ? \&POSIX::WIFSIGNALED
+                                                  : sub { shift() & 127 };
+ $WTERMSIG    = eval { POSIX::WTERMSIG(0);    1 } ? \&POSIX::WTERMSIG
+                                                  : sub { shift() & 127 };
 }
 
 =head1 NAME
@@ -20,11 +28,11 @@ App::Rgit::Repository - Class representing a Git repository.
 
 =head1 VERSION
 
-Version 0.06
+Version 0.08
 
 =cut
 
-our $VERSION = '0.06';
+our $VERSION = '0.08';
 
 =head1 DESCRIPTION
 
@@ -34,7 +42,12 @@ This is an internal class to L<rgit>.
 
 =head1 METHODS
 
-=head2 C<< new dir => $dir [, fake => 1 ] >>
+=head2 C<new>
+
+    my $arr = App::Rgit::Repository->new(
+     dir  => $dir,
+     fake => $bool,
+    );
 
 Creates a new repository starting from C<$dir>.
 If the C<fake> option is passed, C<$dir> isn't checked to be a valid C<git> repository.
@@ -49,7 +62,7 @@ sub new {
 
  my $dir = $args{dir};
  if (defined $dir) {
-  $dir = Cwd::abs_path($dir);
+  $dir = App::Rgit::Utils::abs_path($dir);
  } else {
   $dir = Cwd::cwd;
  }
@@ -108,7 +121,9 @@ sub chdir {
  return 1;
 }
 
-=head2 C<run $conf, @args>
+=head2 C<run>
+
+    my $code = $arr->run($conf, @args);
 
 Runs C<git @args> on the repository for the L<App::Rgit::Config> configuration C<$conf>.
 When the repository isn't fake, the format substitutions applies to C<@args> elements.
@@ -168,12 +183,12 @@ sub run {
  }
 
  my $ret;
- $ret = WEXITSTATUS($?) if WIFEXITED($?);
+ $ret = $WEXITSTATUS->($?) if $WIFEXITED->($?);
  my $sig;
- if (WIFSIGNALED($?)) {
-  $sig = WTERMSIG($?);
+ if ($WIFSIGNALED->($?)) {
+  $sig = $WTERMSIG->($?);
   $conf->warn("git died with signal $sig\n");
-  if ($sig == SIGINT || $sig == SIGQUIT) {
+  if ($sig == POSIX::SIGINT() || $sig == POSIX::SIGQUIT()) {
    $conf->err("Aborting\n");
    exit $sig;
   }
@@ -214,7 +229,8 @@ You can contact me by mail or on C<irc.perl.org> (vincent).
 
 =head1 BUGS
 
-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.
+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.
 
 =head1 SUPPORT