]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - lib/App/Rgit/Repository.pm
In App::Rgit::Repository::new, only make the directory absolute if it's not already
[perl/modules/rgit.git] / lib / App / Rgit / Repository.pm
index 93efb4cfa71eac2fa896ac83595cfb8c4a89368d..83241a15d941d0c9fb3d13ca1a38b8c2ecc321ea 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use Cwd qw/cwd abs_path/;
-use File::Spec::Functions qw/catdir splitdir abs2rel/;
+use File::Spec::Functions qw/catdir splitdir abs2rel file_name_is_absolute/;
 
 use Object::Tiny qw/fake repo bare name work/;
 
@@ -16,11 +16,11 @@ App::Rgit::Repository - Class representing a Git repository.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 =head1 DESCRIPTION
 
@@ -40,11 +40,11 @@ If the C<fake> option is passed, C<$dir> isn't checked to be a valid C<git> repo
 sub new {
  my ($class, %args) = &validate;
  my $dir = $args{dir};
- $dir = abs_path $dir if defined $dir;
+ $dir = abs_path $dir if defined $dir and not file_name_is_absolute $dir;
  $dir = cwd       unless defined $dir;
  my ($repo, $bare, $name, $work);
  if ($args{fake}) {
-  $repo = $dir;
+  $work = $dir;
  } else { 
   my @tries = ($dir);
   push @tries, "$dir.git" unless $dir =~ /\.git$/;
@@ -85,9 +85,9 @@ C<chdir> into the repository's directory.
 
 sub chdir {
  my $self = shift;
- my $repo = $self->repo;
- chdir $repo or do {
-  warn "Couldn't chdir into $repo: $!";
+ my $dir = $self->work;
+ chdir $dir or do {
+  warn "Couldn't chdir into $dir: $!";
   return;
  };
  return 1;