Use anon symbols for safety / reentrancy, no idea if this works :)
[catagits/Gitalist.git] / lib / Gitalist / Git / Project.pm
index 36615f0..5129f12 100644 (file)
@@ -26,8 +26,10 @@ class Gitalist::Git::Project with Gitalist::Git::HasUtils {
     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}/;
 
@@ -158,7 +160,7 @@ Each item is a L<Gitalist::Git::Object>.
 
 =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) {
@@ -167,13 +169,11 @@ Return a L<Gitalist::Git::Object> for the given 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,
         );
     }