Make the version number sane and clean up copyright/license statements everywhere
[catagits/Gitalist.git] / lib / Gitalist / Git / Project.pm
index d4a04aa..ea425e2 100644 (file)
@@ -27,7 +27,6 @@ class Gitalist::Git::Project with Gitalist::Git::HasUtils {
     use Moose::Autobox;
     use List::MoreUtils qw/any zip/;
     use DateTime;
-    use Gitalist::Util qw(to_utf8);
     use Gitalist::Git::Object::Blob;
     use Gitalist::Git::Object::Tree;
     use Gitalist::Git::Object::Commit;
@@ -118,6 +117,14 @@ ArrayRef of hashes containing the name and sha1 of all heads.
     has heads => ( isa => ArrayRef[HashRef],
                    is => 'ro',
                    lazy_build => 1);
+=head2 tags
+
+ArrayRef of hashes containing the name and sha1 of all tags.
+
+=cut
+    has tags => ( isa => ArrayRef[HashRef],
+                   is => 'ro',
+                   lazy_build => 1);
 
 =head2 references
 
@@ -259,13 +266,12 @@ method snapshot (NonEmptySimpleStr :$sha1,
     $format = $formats->{$format};
     my $name = $self->name;
     $name =~ s,([^/])/*\.git$,$1,;
-    my $filename = to_utf8($name);
+    my $filename = $name;
     $filename .= "-$sha1.$format";
     $name =~ s/\047/\047\\\047\047/g;
 
-
     my @cmd = ('archive', "--format=$format", "--prefix=$name/", $sha1);
-    return $self->run_cmd_fh(@cmd);
+    return ($filename, $self->run_cmd_fh(@cmd));
     # TODO - support compressed archives
 }
 
@@ -389,6 +395,32 @@ FIXME Should this return objects?
         return \@ret;
     }
 
+    method _build_tags {
+        my @revlines = $self->run_cmd_list('for-each-ref',
+          '--sort=-creatordate',
+          '--format=%(objectname) %(objecttype) %(refname) %(*objectname) %(*objecttype) %(subject)%00%(creator)',
+         'refs/tags'
+        );
+        my @ret;
+        for my $line (@revlines) {
+            my($refinfo, $creatorinfo) = split /\0/, $line;
+           my($rev, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);
+            my($creator, $epoch, $tz) = ($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);
+            $name =~ s!^refs/tags/!!;
+
+            push @ret, { sha1 => $rev, name => $name };
+
+            #FIXME: That isn't the time I'm looking for..
+            if($epoch and $tz) {
+                my $dt = DateTime->from_epoch(epoch => $epoch);
+                $dt->set_time_zone($tz);
+                $ret[-1]->{last_change} = $dt;
+            }
+        }
+
+        return \@ret;
+    }
+
     method _build_references {
        # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
        # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
@@ -415,26 +447,20 @@ FIXME Should this return objects?
                     map  split(/\n/, $_, 6), split /\0/, $output;
     }
 
+} # end class
+
+__END__
+
 =head1 SEE ALSO
 
 L<Gitalist::Git::Util> L<Gitalist::Git::Object>
 
-=head1 AUTHORS AND COPYRIGHT
-
-  Catalyst application:
-    (C) 2009 Venda Ltd and Dan Brook <dbrook@venda.com>
+=head1 AUTHORS
 
-  Original gitweb.cgi from which this was derived:
-    (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
-    (C) 2005, Christian Gierke
+See L<Gitalist> for authors.
 
 =head1 LICENSE
 
-FIXME - Is this going to be GPLv2 as per gitweb? If so this is broken..
-
-This library is free software. You can redistribute it and/or modify
-it under the same terms as Perl itself.
+See L<Gitalist> for the license.
 
 =cut
-
-} # end class