From: Vincent Pit Date: Sat, 27 Dec 2008 20:40:16 +0000 (+0100) Subject: If everything fails, try to append '.bat' to the git executable on win32 X-Git-Tag: v0.06~7 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=commitdiff_plain;h=47ad8bd4ad6d9bbb04ff48c8948c71732077dbcc If everything fails, try to append '.bat' to the git executable on win32 --- diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index 90afe3b..b360dda 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -12,6 +12,8 @@ use Object::Tiny qw/root git cwd_repo debug/; use App::Rgit::Repository; use App::Rgit::Utils qw/validate :levels/; +use constant IS_WIN32 => $^O eq 'MSWin32'; + =head1 NAME App::Rgit::Config - Base class for App::Rgit configurations. @@ -40,17 +42,31 @@ Creates a new configuration object based on the root directory C<$root> and usin sub new { my ($class, %args) = &validate; + my $root = $args{root}; return unless defined $root and -d $root; $root = abs_path $root unless file_name_is_absolute $root; - return unless defined $args{git} and -x $args{git}; + + my $git = $args{git}; + return unless defined $git; + if (IS_WIN32) { + unless (-x $git) { + $git .= '.bat'; + return unless -x $git; + } + } else { + return unless -x $git; + } + my $conf = 'App::Rgit::Config::Default'; eval "require $conf; 1" or croak "Couldn't load $conf: $@"; + my $r = App::Rgit::Repository->new(fake => 1); return unless defined $r; + $conf->SUPER::new( root => $root, - git => $args{git}, + git => $git, cwd_repo => $r, debug => defined $args{debug} ? int $args{debug} : WARN, );