File::Spec is required instead of File::Spec::Functions.
(my $name = $dist) =~ s{-}{::}g;
my %PREREQ_PM = (
- 'Carp' => 0,
- 'Cwd' => 0,
- 'Exporter' => 0,
- 'File::Find' => 0,
- 'File::Spec::Functions' => 0,
- 'POSIX' => 0,
- 'base' => 0,
+ 'Carp' => 0,
+ 'Cwd' => 0,
+ 'Exporter' => 0,
+ 'File::Find' => 0,
+ 'File::Spec' => 0,
+ 'POSIX' => 0,
+ 'base' => 0,
);
my %META = (
'ExtUtils::MakeMaker' => 0,
},
build_requires => {
- 'Cwd' => 0,
- 'ExtUtils::MakeMaker' => 0,
- 'Exporter' => 0,
- 'File::Spec::Functions' => 0,
- 'File::Temp' => 0,
- 'POSIX' => 0,
- 'Test::More' => 0,
- 'base' => 0,
+ 'Cwd' => 0,
+ 'ExtUtils::MakeMaker' => 0,
+ 'Exporter' => 0,
+ 'File::Spec' => 0,
+ 'File::Temp' => 0,
+ 'POSIX' => 0,
+ 'Test::More' => 0,
+ 'base' => 0,
%PREREQ_PM,
},
recommends => {
use strict;
use warnings;
-use Carp qw/croak/;
-use Config qw/%Config/;
-use Cwd qw/cwd/;
-use File::Spec::Functions qw/catfile path/;
+use Carp qw/croak/;
+use Config qw/%Config/;
+use Cwd qw/cwd/;
+use File::Spec (); # catfile, path
use App::Rgit;
use App::Rgit::Utils qw/:levels/;
my $git = $ENV{GIT_EXEC_PATH};
unless (defined $git) {
- for (path) {
- my $g = catfile $_, 'git';
+ for (File::Spec->path) {
+ my $g = File::Spec->catfile($_, 'git');
if (-x $g) {
$git = $g;
last;
=head1 DEPENDENCIES
-The core modules L<Carp>, L<Config>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions> and L<POSIX>.
+The core modules L<Carp>, L<Config>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec> and L<POSIX>.
=head1 AUTHOR
use strict;
use warnings;
-use Carp ();
-use Cwd qw/abs_path/;
-use File::Spec::Functions qw/canonpath/;
+use Carp (); # confess
+use Cwd (); # abs_path
+use File::Spec (); # canonpath
use App::Rgit::Repository;
use App::Rgit::Utils qw/:levels/;
my $root = $args{root};
return unless defined $root and -d $root;
- $root = canonpath abs_path $root;
+ $root = File::Spec->canonpath(Cwd::abs_path($root));
my $git = $args{git};
return unless defined $git;
} else {
return unless -x $git;
}
- $git = canonpath abs_path $git;
+ $git = File::Spec->canonpath(Cwd::abs_path($git));
my $conf = 'App::Rgit::Config::Default';
eval "require $conf; 1" or Carp::confess("Couldn't load $conf: $@");
use strict;
use warnings;
-use Cwd qw/cwd abs_path/;
-use File::Spec::Functions qw/canonpath catdir splitdir abs2rel/;
-use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/;
+use Cwd (); # cwd, abs_path
+use File::Spec (); # canonpath, catdir, splitdir, abs2rel
+use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG SIGINT SIGQUIT/;
BEGIN {
no warnings 'redefine';
my $dir = $args{dir};
if (defined $dir) {
- $dir = abs_path $dir;
+ $dir = Cwd::abs_path($dir);
} else {
- $dir = cwd;
+ $dir = Cwd::cwd;
}
- $dir = canonpath $dir;
+ $dir = File::Spec->canonpath($dir);
my ($repo, $bare, $name, $work);
if ($args{fake}) {
and -d "$dir/objects"
and -e "$dir/HEAD";
- my @chunks = splitdir $dir;
+ my @chunks = File::Spec->splitdir($dir);
my $last = pop @chunks;
return unless defined $last;
- if ($last eq '.git') {
+ if (@chunks and $last eq '.git') {
$bare = 0;
$name = $chunks[-1];
- $work = catdir @chunks;
+ $work = File::Spec->catdir(@chunks);
} elsif ($last =~ /(.+)\.git$/) {
$bare = 1;
$name = $1;
- $work = catdir @chunks, $last;
+ $work = File::Spec->catdir(@chunks, $last);
} else {
return;
}
=cut
-sub _abs2rel {
- my $a = &abs2rel;
+my $abs2rel = sub {
+ my $a = File::Spec->abs2rel(@_);
$a = $_[0] unless defined $a;
$a;
-}
+};
my %escapes = (
'%' => sub { '%' },
'n' => sub { shift->name },
- 'g' => sub { _abs2rel(shift->repo, shift->root) },
+ 'g' => sub { $abs2rel->(shift->repo, shift->root) },
'G' => sub { shift->repo },
- 'w' => sub { _abs2rel(shift->work, shift->root) },
+ 'w' => sub { $abs2rel->(shift->work, shift->root) },
'W' => sub { shift->work },
'b' => sub {
my ($self, $conf) = @_;
- _abs2rel($self->bare ? $self->repo : $self->work . '.git', $conf->root)
+ $abs2rel->(
+ $self->bare ? $self->repo : $self->work . '.git',
+ $conf->root
+ );
},
'B' => sub { $_[0]->bare ? $_[0]->repo : $_[0]->work . '.git' },
'R' => sub { $_[1]->root },
my $self = shift;
my $conf = shift;
return unless $conf->isa('App::Rgit::Config');
+
my @args = @_;
+
unless ($self->fake) {
s/%($e)/$escapes{$1}->($self, $conf)/eg for @args;
}
+
unshift @args, $conf->git;
$conf->info('Executing "', join(' ', @args), '" into ', $self->work, "\n");
+
{
local $ENV{GIT_DIR} = $self->repo if exists $ENV{GIT_DIR};
local $ENV{GIT_EXEC_PATH} = $conf->git if exists $ENV{GIT_EXEC_PATH};
system { $args[0] } @args;
}
+
if ($? == -1) {
$conf->crit("Failed to execute git: $!\n");
return;
}
+
my $ret;
$ret = WEXITSTATUS($?) if WIFEXITED($?);
my $sig;
} elsif ($ret) {
$conf->info("git returned $ret\n");
}
+
return wantarray ? ($ret, $sig) : $ret;
}
use strict;
use warnings;
-use Cwd qw/cwd/;
-use File::Spec::Functions qw/catdir/;
+use Cwd (); # cwd
+use File::Spec (); # catdir
use Test::More tests => 42;
use App::Rgit::Repository;
-my $cwd = cwd;
-my $t = catdir($cwd, 't');
+my $cwd = Cwd::cwd;
+my $t = File::Spec->catdir($cwd, 't');
chdir $t or die "chdir($t): $!";
$res = eval {
use strict;
use warnings;
-use Cwd qw/cwd abs_path/;
-use File::Spec::Functions qw/catdir catfile/;
-use File::Temp qw/tempfile tempdir/;
+use Cwd qw/cwd abs_path/;
+use File::Spec (); # catdir, catfile
+use File::Temp qw/tempfile tempdir/;
use Test::More;
while (my ($d, $v) = each %$tree) {
if (ref $v) {
- my $dir = catdir($prefix, $d);
+ my $dir = File::Spec->catdir($prefix, $d);
mkdir $dir or die "mkdir($dir): $!";
my @r = build($v, $dir);
push @ret, [
$_->[0],
ref eq 'main' ? @{$_}[1 .. 3]
- : map catdir($d, $_), @{$_}[1 .. 3]
+ : map File::Spec->catdir($d, $_), @{$_}[1 .. 3]
];
}
}
} else {
- my $file = catfile($prefix, $d);
+ my $file = File::Spec->catfile($prefix, $d);
open my $fh, '>', $file or die "open($file): $!";
print $fh $v;
close $fh;
sub repo {
my ($n, $bare) = @_;
- return $bare ? [ $n, "$n.git", "$n.git", "$n.git" ]
- : [ $n, catdir($n, '.git'), $n, "$n.git" ]
+ return $bare ? [ $n, "$n.git", "$n.git", "$n.git" ]
+ : [ $n, File::Spec->catdir($n, '.git'), $n, "$n.git" ]
}
my $tmpdir = tempdir(CLEANUP => 1);
@expected = map [
@$_,
- map(catdir($tmpdir, $_), @{$_}[1 .. 3]),
+ map(File::Spec->catdir($tmpdir, $_), @{$_}[1 .. 3]),
$tmpdir,
'%n', '%x'
], @expected;
use strict;
use warnings;
-use Cwd qw/abs_path/;
-use File::Temp qw/tempfile/;
-use File::Spec::Functions qw/curdir catfile/;
-use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG/;
+use Cwd qw/abs_path/;
+use File::Temp qw/tempfile/;
+use File::Spec (); # curdir, catfile
+use POSIX qw/WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG/;
BEGIN {
no warnings 'redefine';
'version',
);
- my $git = catfile(curdir, qw/t bin git/);
+ my $git = File::Spec->catfile(File::Spec->curdir, qw/t bin git/);
if ($^O eq 'MSWin32') {
unless (-x $git) {
$git .= '.bat';