use Moose;
use namespace::autoclean;
-use Gitalist;
+BEGIN { extends 'Catalyst::Model' }
+
use DateTime;
use Path::Class;
use Carp qw/croak/;
use List::MoreUtils qw/any/;
use Scalar::Util qw/blessed/;
-BEGIN { extends 'Catalyst::Model' }
-
-has git => (
- is => 'ro',
- isa => 'Str',
- lazy => 1,
- default => sub {
- my $git;
+{
+ my $git;
+ sub git {
+ return $git
+ if $git;
if (my $config_git = Gitalist->config->{git}) {
$git = $config_git if -x $config_git;
}
return $git;
- },
-);
+ }
+}
sub is_git_repo {
my ($self, $dir) = @_;
- #FIXME: Only handles bare repos. Is that enough?
- return -f $dir->file('HEAD');
+ return -f $dir->file('HEAD') || -f $dir->file('.git/HEAD');
}
sub project_info {
chomp $props{description};
};
- if ($props{description} =~ /^Unnamed repository;/) {
+ if ($props{description} && $props{description} =~ /^Unnamed repository;/) {
delete $props{description};
}
my $obj = $base->subdir($file);
next unless -d $obj;
next unless $self->is_git_repo($obj);
+ # XXX Leaky abstraction alert!
+ $obj = $obj->subdir('.git')
+ if -d $obj->subdir('.git');
push @ret, {
- name => ($obj->dir_list)[-1],
+ name => (File::Spec->splitdir($base->subdir($file)))[-1],
$self->get_project_properties($obj),
};
}