use MooseX::Types::Moose qw/Str Maybe Bool HashRef ArrayRef/;
use List::MoreUtils qw/any zip/;
use DateTime;
+ use Gitalist::Git::Object::Blob;
+ use Gitalist::Git::Object::Tree;
use Gitalist::Git::Object::Commit;
- use aliased 'Gitalist::Git::Object';
+ use Gitalist::Git::Object::Tag;
our $SHA1RE = qr/[0-9a-fA-F]{40}/;
=head2 get_object ($sha1)
-Return a L<Gitalist::Git::Object> for the given sha1.
+Return an appropriate subclass of L<Gitalist::Git::Object> for the given sha1.
=cut
method get_object (NonEmptySimpleStr $sha1) {
}
my $type = $self->run_cmd('cat-file', '-t', $sha1);
chomp($type);
- my $class = 'Gitalist::Git::Object';
- if ($type eq 'commit') {
- $class .= '::' . ucfirst($type);
- };
- return $class->new(
+ my $class = 'Gitalist::Git::Object::' . ucfirst($type);
+ $class->new(
project => $self,
sha1 => $sha1,
+ type => $type,
);
}