Stop ->_build_project reinventing the wheel.
Zachary Stevens [Sun, 13 Dec 2009 01:52:13 +0000 (01:52 +0000)]
lib/Gitalist/Git/Repo.pm
t/lib/repositories/file [new file with mode: 0644]

index 62879d7..a8fff7e 100644 (file)
@@ -38,18 +38,15 @@ class Gitalist::Git::Repo {
 
     ## Builders
     method _build_projects {
-        my $base = $self->repo_dir;
-        my $dh = $base->open || die "Could not open $base";
+        my $dh = $self->repo_dir->open || die "Could not open repo_dir";
         my @ret;
-        while (my $file = $dh->read) {
-            next if $file =~ /^.{1,2}$/;
-
-            my $obj = $base->subdir($file);
-            next unless -d $obj;
-            next unless $self->_is_git_repo($obj);
-
-            push @ret, $self->get_project($file);
-        }
+        while (my $dir_entry = $dh->read) {
+            # try to get a project for each entry in repo_dir
+             eval {
+                 my $p = $self->get_project($dir_entry);
+                 push @ret, $p;
+            };
+         }
 
         return [sort { $a->name cmp $b->name } @ret];
     }
diff --git a/t/lib/repositories/file b/t/lib/repositories/file
new file mode 100644 (file)
index 0000000..e69de29