my $project = $c->stash->{Project};
$c->detach('error_404') unless $project;
my $commit = $self->_get_object($c);
- my @heads = $project->heads;
+ my @heads = @{$project->heads};
my $maxitems = Gitalist->config->{paging}{summary} || 10;
$c->stash(
commit => $commit,
my $project = $c->stash->{Project};
$c->stash(
commit => $self->_get_object($c),
- heads => [$project->heads],
+ heads => $project->heads,
action => 'heads',
);
}
=head2 heads
-Returns a list of hashes containing the name and sha1 of all heads.
+ArrayRef of hashes containing the name and sha1 of all heads.
=cut
- method heads {
+ has heads => ( isa => ArrayRef[HashRef], is => 'ro', lazy_build => 1);
+
+ method _build_heads {
my @revlines = $self->run_cmd_list(qw/for-each-ref --sort=-committerdate /, '--format=%(objectname)%00%(refname)%00%(committer)', 'refs/heads');
my @ret;
for my $line (@revlines) {
}
}
- return @ret;
+ return \@ret;
}
=head2 references
-Returns a hash of references.
+Hashref of ArrayRefs for each reference.
=cut
is($proj->info->{name}, qw/repo1/, 'repo name in info hash');
-my @heads = $proj->heads;
+my %references = %{$proj->references};
+ok(keys %references >= 2, '->references hash has elements');
+is($references{'36c6c6708b8360d7023e8a1649c45bcf9b3bd818'}->[0], 'heads/master', 'reference looks ok');
+my @heads = @{$proj->heads};
ok(scalar @heads > 1, '->heads list has more than one element');
my %head = %{$heads[1]};
ok(keys %head == 3, '->heads[1] has the right number of keys');