}
method _build__util {
- my $util = Gitalist::Git::Util->new(
- gitdir => $self->project_dir($self->path),
+ Gitalist::Git::Util->new(
+ gitdir => $self->path,
);
- return $util;
}
method _build_description {
return @ret;
}
- # FIXME - Why not just stay in Path::Class land and return a P::C::D here?
- method project_dir {
- my $dir = $self->path->stringify;
- $dir .= '/.git'
- if -f dir($dir)->file('.git/HEAD');
- return $dir;
- }
-
# Compatibility
=head2 info
=cut
method _is_git_repo ($dir) {
- return -f $dir->file('HEAD') || -f $dir->file('.git/HEAD');
+ return -f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD');
}
=head2 project_dir
=cut
method project_dir ($project) {
- my $dir = blessed($project) && $project->isa('Path::Class::Dir')
- ? $project->stringify
- : $self->dir_from_project_name($project);
-
- $dir .= '/.git'
- if -f dir($dir)->file('.git/HEAD');
-
- return $dir;
+ -f $project->file('.git', 'HEAD')
+ ? $project->subdir('.git')
+ : $project;
}
=head2 list_projects
next unless -d $obj;
next unless $self->_is_git_repo($obj);
- # XXX Leaky abstraction alert!
- my $is_bare = !-d $obj->subdir('.git');
-
- my $name = (File::Spec->splitdir($obj))[-1];
- push @ret, Gitalist::Git::Project->new( name => $name,
- path => $obj,
+ # FIXME - Is resolving project_dir here sane?
+ # I think not, just pass $obj down, and
+ # resolve $project->path and $project->is_bare
+ # in BUILDARGS
+ push @ret, Gitalist::Git::Project->new( name => $file,
+ path => $self->project_dir($obj),
);
}
use File::Which;
use Git::PurePerl;
use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
- use MooseX::Types::Moose qw/Str/;
- has gitdir => ( isa => Str, is => 'ro', required => 1 );
+ has gitdir => ( isa => 'Path::Class::Dir', is => 'ro', required => 1 );
has _git => ( isa => NonEmptySimpleStr, is => 'ro', lazy_build => 1 );
sub _build__git {
my $git = File::Which::which('git');