Lose some code by not converting to/from path::class objects, and also by flattening...
[catagits/Gitalist.git] / lib / Gitalist / Git / Repo.pm
index 6470cbf..fe18e97 100644 (file)
@@ -16,7 +16,7 @@ C<git> repo.
 =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
@@ -26,14 +26,9 @@ The directory under which the given project will reside i.e C<.git/..>
 =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
@@ -54,12 +49,12 @@ each item will contain the contents of L</project_info>.
             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),
                                  );
         }