Added the /tags action.
Dan Brook [Fri, 20 Nov 2009 13:10:16 +0000 (13:10 +0000)]
Added POD for PODless actions.

lib/Gitalist/Controller/Root.pm
lib/Gitalist/Git/Project.pm
root/_heads.tt2
root/tags.tt2 [new file with mode: 0644]

index f93895a..f4ab6db 100644 (file)
@@ -117,6 +117,22 @@ sub heads : Local {
   );
 }
 
+=head2 tags
+
+The current list of tags in the repo.
+
+=cut
+
+sub tags : Local {
+  my ( $self, $c ) = @_;
+  my $project = $c->stash->{Project};
+  $c->stash(
+    commit => $self->_get_object($c),
+    tags   => $project->tags,
+    action => 'tags',
+  );
+}
+
 =head2 blob
 
 The blob action i.e the contents of a file.
@@ -334,6 +350,12 @@ sub reflog : Local {
   );
 }
 
+=head2 search
+
+The action for the search form.
+
+=cut
+
 sub search : Local {
   my($self, $c) = @_;
   $c->stash(current_action => 'GitRepos');
@@ -359,11 +381,23 @@ sub search : Local {
   );
 }
 
+=head2 search_help
+
+Provides some help for the search form.
+
+=cut
+
 sub search_help : Local {
     my ($self, $c) = @_;
     $c->stash(template => 'search_help.tt2');
 }
 
+=head2 atom
+
+Provides an atom feed for a given project.
+
+=cut
+
 sub atom : Local {
   my($self, $c) = @_;
 
@@ -395,6 +429,12 @@ sub atom : Local {
   $c->response->status(200);
 }
 
+=head2 rss
+
+Provides an RSS feed for a given project.
+
+=cut
+
 sub rss : Local {
   my ($self, $c) = @_;
 
@@ -430,11 +470,23 @@ sub rss : Local {
   $c->response->status(200);
 }
 
+=head2 patch
+
+A raw patch for a given commit.
+
+=cut
+
 sub patch : Local {
     my ($self, $c) = @_;
     $c->detach('patches', [1]);
 }
 
+=head2 patches
+
+The patcheset for a given commit ???
+
+=cut
+
 sub patches : Local {
     my ($self, $c, $count) = @_;
     $count ||= Gitalist->config->{patches}{max};
@@ -446,6 +498,12 @@ sub patches : Local {
     $c->response->status(200);
 }
 
+=head2 snapshot
+
+Provides a snapshot of a given commit.
+
+=cut
+
 sub snapshot : Local {
     my ($self, $c) = @_;
     my $format = $c->req->param('sf') || 'tgz';
@@ -502,10 +560,6 @@ sub auto : Private {
   );
 }
 
-sub tags : Local {
-    # FIXME - implement snapshot
-    Carp::croak "Not implemented.";
-}
 sub project_index : Local {
     # FIXME - implement snapshot
     Carp::croak "Not implemented.";
index ae4ac0e..981e824 100644 (file)
@@ -117,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
 
@@ -387,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^{}
index c886711..0eb77e7 100644 (file)
@@ -1,4 +1,4 @@
-<table class='heads listing'>
+<table class='[% action %] listing'>
  <thead>
   <tr>
    <th>HEAD</th>
diff --git a/root/tags.tt2 b/root/tags.tt2
new file mode 100644 (file)
index 0000000..768e842
--- /dev/null
@@ -0,0 +1,7 @@
+[% INCLUDE 'nav/actions.tt2' object = commit %]
+
+<div>
+[% Project.name %]
+</div>
+
+[% INCLUDE '_heads.tt2' heads = tags %]