3 class Gitalist::Git::Repo {
4 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
5 use MooseX::Types::Path::Class qw/Dir/;
6 use MooseX::Types::Moose qw/ArrayRef/;
7 use aliased 'Gitalist::Git::Project';
16 method project (NonEmptySimpleStr $project) {
19 path => $self->repo_dir->subdir($project),
26 Determine whether a given directory (as a L<Path::Class::Dir> object) is a
31 method _is_git_repo ($dir) {
32 return -f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD');
37 For the C<repo_dir> specified in the config return an array of projects where
38 each item will contain the contents of L</project_info>.
43 isa => ArrayRef['Gitalist::Git::Project'],
44 reader => 'list_projects',
48 method _build_projects {
49 my $base = $self->repo_dir;
50 my $dh = $base->open || die "Could not open $base";
52 while (my $file = $dh->read) {
53 next if $file =~ /^.{1,2}$/;
55 my $obj = $base->subdir($file);
57 next unless $self->_is_git_repo($obj);
59 push @ret, $self->project($file);
62 return [sort { $a->name cmp $b->name } @ret];