use MooseX::Types::Moose qw/Str Maybe Bool HashRef ArrayRef/;
use List::MoreUtils qw/any zip/;
use DateTime;
- use Gitalist::Git::Object::Commit;
use Gitalist::Git::Object::Blob;
- use aliased 'Gitalist::Git::Object';
+ use Gitalist::Git::Object::Tree;
+ use Gitalist::Git::Object::Commit;
+ 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';
- use Moose::Autobox;
- if ($type eq ['commit', 'blob']->any) {
- $class .= '::' . ucfirst($type);
- };
- return $class->new(
+ my $class = 'Gitalist::Git::Object::' . ucfirst($type);
+ $class->new(
project => $self,
sha1 => $sha1,
type => $type,
return @revs;
}
+=head2 snapshot($head?, $format)
+
+Generate an archived snapshot of the repository.
+Returns a filehandle to read from.
+
+=cut
+
+method snapshot (Gitalist::Git::Object :$commit,
+ NonEmptySimpleStr :$format
+ ) {
+ return $commit->snapshot;
+ }
+
=head2 diff($commit, $patch?, $parent?, $file?)
Generate a diff from a given L<Gitalist::Git::Object>.