X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=lib%2FApp%2FRgit%2FRepository.pm;h=83241a15d941d0c9fb3d13ca1a38b8c2ecc321ea;hp=93efb4cfa71eac2fa896ac83595cfb8c4a89368d;hb=a478eb47772af0e18b0b557f7830de989e7cb44d;hpb=19bee8f647bfe6c94c5cb3cf6a60d7a43cbca222 diff --git a/lib/App/Rgit/Repository.pm b/lib/App/Rgit/Repository.pm index 93efb4c..83241a1 100644 --- a/lib/App/Rgit/Repository.pm +++ b/lib/App/Rgit/Repository.pm @@ -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 option is passed, C<$dir> isn't checked to be a valid C 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 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;