]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - lib/App/Rgit/Config.pm
Bump copyright year
[perl/modules/rgit.git] / lib / App / Rgit / Config.pm
index 90afe3b35cf58b9147ef135710de14eaaca1a814..d299283eb8db72cfaea64cf23cfe4e4becfa0cc8 100644 (file)
@@ -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,
  );
@@ -120,7 +136,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2008 Vincent Pit, all rights reserved.
+Copyright 2008-2009 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.