3 class Gitalist::Git::Project {
4 # FIXME, use Types::Path::Class and coerce
5 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
8 use Gitalist::Git::Util;
10 has name => ( isa => NonEmptySimpleStr,
12 has path => ( isa => "Path::Class::Dir",
15 has description => ( isa => NonEmptySimpleStr,
19 has owner => ( isa => NonEmptySimpleStr,
23 has last_change => ( isa => 'DateTime',
27 has _util => ( isa => 'Gitalist::Git::Util',
30 handles => [ 'run_cmd' ],
34 my $util = Gitalist::Git::Util->new(
35 gitdir => $self->path,
40 method _build_description {
41 my $description = $self->path->file('description')->slurp;
47 my $owner = (getpwuid $self->path->stat->uid)[6];
52 method _build_last_change {
54 my $output = $self->run_cmd(
55 qw{ for-each-ref --format=%(committer)
56 --sort=-committerdate --count=1 refs/heads
58 if (my ($epoch, $tz) = $output =~ /\s(\d+)\s+([+-]\d+)$/) {
59 my $dt = DateTime->from_epoch(epoch => $epoch);
60 $dt->set_time_zone($tz);
66 method project_dir (Path::Class::Dir $project) {
67 my $dir = $project->stringify;
69 if -f dir($dir)->file('.git/HEAD');
77 Returns a hash containing properties of this project. The keys will
81 description (empty if .git/description is empty/unnamed)
90 description => $self->description,
91 owner => $self->owner,
92 last_change => $self->last_change,