Clean hash_by_path's signature.
[catagits/Gitalist.git] / lib / Gitalist / Git / Repository.pm
index 5818fb5..941a4a0 100644 (file)
@@ -3,19 +3,18 @@ use MooseX::Declare;
 class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     # FIXME, use Types::Path::Class and coerce
     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
+    use MooseX::Types::Path::Class qw/Dir/;
     use MooseX::Types::Moose qw/Str Maybe Bool HashRef ArrayRef/;
-    use Gitalist::Git::Types qw/SHA1 DateTime Dir/;
+    use Gitalist::Git::Types qw/SHA1/;
     use Moose::Autobox;
     use List::MoreUtils qw/any zip/;
-    use aliased 'DateTime' => 'DT';
+    use DateTime;
     use Encode qw/decode/;
     use I18N::Langinfo qw/langinfo CODESET/;
     use Gitalist::Git::Object::Blob;
     use Gitalist::Git::Object::Tree;
     use Gitalist::Git::Object::Commit;
     use Gitalist::Git::Object::Tag;
-    
-    with 'Gitalist::Serializeable';
 
     our $SHA1RE = qr/[0-9a-fA-F]{40}/;
 
@@ -35,8 +34,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                   is => 'ro', required => 1 );
 
     has path => ( isa => Dir,
-                  is => 'ro', required => 1,
-                  traits => [qw/ DoNotSerialize /] );
+                  is => 'ro', required => 1);
 
     has description => ( isa => Str,
                          is => 'ro',
@@ -48,7 +46,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                    lazy_build => 1,
                );
 
-    has last_change => ( isa => Maybe[DateTime],
+    has last_change => ( isa => Maybe['DateTime'],
                          is => 'ro',
                          lazy_build => 1,
                      );
@@ -72,7 +70,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                         lazy_build => 1 );
 
     method BUILD {
-        $self->$_() for qw/last_change owner description/; # Ensure to build early.
+        $self->$_() for qw/last_change owner description /; # Ensure to build early.
     }
 
     ## Public methods
@@ -110,7 +108,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
         );
     }
 
-    method hash_by_path ($base, $path = '', $type?) {
+    method hash_by_path ($base, $path) {
         $path =~ s{/+$}();
         # FIXME should this really just take the first result?
         my @paths = $self->run_cmd('ls-tree', $base, '--', $path)
@@ -119,9 +117,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
 
         #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
         $line =~ m/^([0-9]+) (.+) ($SHA1RE)\t/;
-        return defined $type && $type ne $2
-            ? ()
-                : $3;
+        return $3;
     }
 
     method list_revs ( NonEmptySimpleStr :$sha1!,
@@ -181,16 +177,6 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
         # TODO - support compressed archives
     }
 
-    method diff ( Gitalist::Git::Object :$commit!,
-                  Bool :$patch?,
-                  Maybe[NonEmptySimpleStr] :$parent?,
-                  NonEmptySimpleStr :$filename?
-              ) {
-              return $commit->diff( patch => $patch,
-                                    parent => $parent,
-                                    filename => $filename);
-    }
-
     method reflog (@logargs) {
         my @entries
             =  $self->run_cmd(qw(log -g), @logargs)
@@ -263,7 +249,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                 --sort=-committerdate --count=1 refs/heads
           });
         if (my ($epoch, $tz) = $output =~ /\s(\d+)\s+([+-]\d+)$/) {
-            my $dt = DT->from_epoch(epoch => $epoch);
+            my $dt = DateTime->from_epoch(epoch => $epoch);
             $dt->set_time_zone($tz);
             $last_change = $dt;
         }
@@ -281,7 +267,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
 
             #FIXME: That isn't the time I'm looking for..
             if (my ($epoch, $tz) = $line =~ /\s(\d+)\s+([+-]\d+)$/) {
-                my $dt = DT->from_epoch(epoch => $epoch);
+                my $dt = DateTime->from_epoch(epoch => $epoch);
                 $dt->set_time_zone($tz);
                 $ret[-1]->{last_change} = $dt;
             }
@@ -307,7 +293,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
 
             #FIXME: That isn't the time I'm looking for..
             if($epoch and $tz) {
-                my $dt = DT->from_epoch(epoch => $epoch);
+                my $dt = DateTime->from_epoch(epoch => $epoch);
                 $dt->set_time_zone($tz);
                 $ret[-1]->{last_change} = $dt;
             }
@@ -413,9 +399,9 @@ Each item is a L<Gitalist::Git::Object>.
 
 Return an appropriate subclass of L<Gitalist::Git::Object> for the given sha1.
 
-=head2 hash_by_path ($sha1, $path, $type?)
+=head2 hash_by_path ($commit, $path)
 
-Returns the sha1 for a given path, optionally limited by type.
+Returns the tree/file sha1 for a given path in a commit.
 
 =head2 list_revs ($sha1, $count?, $skip?, \%search?, $file?)