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 Gitalist::Git::Project;
15 method project (NonEmptySimpleStr $project) {
16 return Gitalist::Git::Project->new(
18 path => $self->repo_dir->subdir($project),
25 Determine whether a given directory (as a L<Path::Class::Dir> object) is a
30 method _is_git_repo ($dir) {
31 return -f $dir->file('HEAD') || -f $dir->file('.git', 'HEAD');
36 For the C<repo_dir> specified in the config return an array of projects where
37 each item will contain the contents of L</project_info>.
42 isa => ArrayRef['Gitalist::Git::Project'],
43 reader => 'list_projects',
47 method _build_projects {
48 my $base = $self->repo_dir;
49 my $dh = $base->open || die "Could not open $base";
51 while (my $file = $dh->read) {
52 next if $file =~ /^.{1,2}$/;
54 my $obj = $base->subdir($file);
56 next unless $self->_is_git_repo($obj);
58 push @ret, Gitalist::Git::Project->new(
64 return [sort { $a->name cmp $b->name } @ret];