Merge
Tomas Doran [Tue, 3 Nov 2009 00:17:10 +0000 (00:17 +0000)]
Makefile.PL
lib/Gitalist/Model/Git.pm
root/_diff.tt2
root/default.tt2
root/index.tt2
t/02pod.t [deleted file]
t/03podcoverage.t [deleted file]
t/author/notabs.t [new file with mode: 0644]
t/author/pod.t [new file with mode: 0644]
t/author/podcoverage.t [new file with mode: 0644]

index d760315..a1824c3 100644 (file)
@@ -1,7 +1,11 @@
 #!/usr/bin/env perl
 # IMPORTANT: if you delete this file your app will not work as
 # expected.  You have been warned.
+use strict;
+use warnings;
 use inc::Module::Install;
+use Module::Install::AuthorRequires;
+use Module::Install::AuthorTests;
 
 name 'Gitalist';
 all_from 'lib/Gitalist.pm';
@@ -35,10 +39,16 @@ requires 'Syntax::Highlight::Engine::Kate';
 requires 'Moose::Autobox';
 requires 'DateTime::Format::Human::Duration';
 
+author_requires 'Test::NoTabs';
+author_requires 'Test::Pod' => '1.14';
+author_requires 'Test::Pod::Coverage' => '1.04';
+
 test_requires 'Test::More' => '0.88';
 
 catalyst;
 
+author_tests 't/author';
+
 install_script glob('script/*.pl');
 auto_install;
 WriteAll;
index 1231ba0..9e824f2 100644 (file)
@@ -155,7 +155,7 @@ sub project_dir {
        : $self->dir_from_project_name($project);
 
   $dir .= '/.git'
-      if -f dir($dir)->file('.git/HEAD');
+       if -f dir($dir)->file('.git/HEAD');
 
   return $dir;
 }
@@ -192,10 +192,10 @@ sub command {
 Returns a hash corresponding to a given project's properties. The keys will
 be:
 
-    name
-    description (empty if .git/description is empty/unnamed)
-    owner
-    last_change
+       name
+       description (empty if .git/description is empty/unnamed)
+       owner
+       last_change
 
 =cut
 
@@ -299,10 +299,10 @@ Find the hash of a given head (defaults to HEAD) of given (or current) project.
 =cut
 
 sub head_hash {
-  my ($self, $head) = @_;
+  my ($self, $head, $project) = @_;
 
-  my($output) = $self->command(qw/rev-parse --verify/, $head || 'HEAD' );
-  return unless $output;
+  my $output = $self->run_cmd_in($project || $self->project, qw/rev-parse --verify/, $head || 'HEAD' );
+  return unless defined $output;
 
   my($sha1) = $output =~ /^($SHA1RE)$/;
   return $sha1;
@@ -313,22 +313,21 @@ sub head_hash {
 For a given tree sha1 return an array describing the tree's contents. Where
 the keys for each item will be:
 
-    mode
-    type
-    object
-    file
+       mode
+       type
+       object
+       file
 
 =cut
 
 sub list_tree {
-  my ($self, $sha1) = @_;
+  my ($self, $rev, $project) = @_;
 
-  $sha1 = $self->head_hash($sha1)
-       if !$sha1 or $sha1 !~ $SHA1RE;
+  $project ||= $self->project;
+  $rev ||= $self->head_hash($project);
 
-  my($output) = $self->command(qw/ls-tree -z/, $sha1);
-  return
-       unless $output;
+  my $output = $self->run_cmd_in($project, qw/ls-tree -z/, $rev);
+  return unless defined $output;
 
   my @ret;
   for my $line (split /\0/, $output) {
@@ -336,7 +335,7 @@ sub list_tree {
 
     push @ret, {
       mode    => oct $mode,
-      # XXX I wonder why directories always turn up as 040000 ...
+         # XXX I wonder why directories always turn up as 040000 ...
       modestr => $self->get_object_mode_string({mode=>oct $mode}),
       type    => $type,
       object  => $object,
@@ -365,10 +364,10 @@ sub get_object_mode_string {
 =cut
 
 sub get_object_type {
-  my ($self, $object) = @_;
+  my ($self, $object, $project) = @_;
 
-  my($output) = $self->command(qw/cat-file -t/, $object)
-    or return;
+  chomp(my $output = $self->run_cmd_in($project || $self->project, qw/cat-file -t/, $object));
+  return unless $output;
 
   return $output;
 }
@@ -380,14 +379,14 @@ Return the contents of a given file.
 =cut
 
 sub cat_file {
-  my ($self, $object) = @_;
+  my ($self, $object, $project) = @_;
 
   my $type = $self->get_object_type($object, $self->project);
   die "object `$object' is not a file\n"
     if (!defined $type || $type ne 'blob');
 
-  my($output) = $self->command(qw/cat-file -p/, $object)
-    or return;
+  my $output = $self->run_cmd_in($project || $self->project, qw/cat-file -p/, $object);
+  return unless $output;
 
   return $output;
 }
@@ -406,7 +405,7 @@ sub hash_by_path {
   my($line) = $self->command('ls-tree', $base, '--', $path)
     or return;
 
-  #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa    panic.c'
+  #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa       panic.c'
   $line =~ m/^([0-9]+) (.+) ($SHA1RE)\t/;
   return defined $type && $type ne $2
     ? ()
@@ -441,8 +440,8 @@ sub raw_diff {
   my ($self, @args) = @_;
 
   return $self->command(
-      qw(diff-tree -r -M --no-commit-id --full-index),
-      @args
+         qw(diff-tree -r -M --no-commit-id --full-index),
+         @args
   );
 }
 
@@ -492,15 +491,15 @@ sub diff {
   );
 
   my @out = $self->raw_diff(
-    ( $args{patch} ? '--patch-with-raw' : () ),
-      $parent, $args{commit}->sha1, @etc
+       ( $args{patch} ? '--patch-with-raw' : () ),
+         $parent, $args{commit}->sha1, @etc
   );
 
   # XXX Yes, there is much wrongness having parse_diff_tree be destructive.
   my @difftree = $self->parse_diff_tree(\@out);
 
   return \@difftree
-    unless $args{patch};
+       unless $args{patch};
 
   # The blank line between the tree and the patch.
   shift @out;
@@ -554,7 +553,7 @@ sub parse_diff_tree {
   my @keys = qw(modesrc modedst sha1src sha1dst status src dst);
   my @ret;
   while(@$diff and $diff->[0] =~ /^:\d+/) {
-    my $line = shift @$diff;
+       my $line = shift @$diff;
     # see. man git-diff-tree for more info
     # mode src, mode dst, sha1 src, sha1 dst, status, src[, dst]
     my @vals = $line =~ /^:(\d+) (\d+) ($SHA1RE) ($SHA1RE) ([ACDMRTUX]\d*)\t([^\t]+)(?:\t([^\n]+))?$/;
@@ -563,8 +562,8 @@ sub parse_diff_tree {
     $line{file}   = $line{src};
     $line{sha1}   = $line{sha1dst};
     $line{is_new} = $line{sha1src} =~ /^0+$/
-        if $line{sha1src};
-    @line{qw/status sim/} = $line{status} =~ /(R)(\d+)/
+               if $line{sha1src};
+       @line{qw/status sim/} = $line{status} =~ /(R)(\d+)/
       if $line{status} =~ /^R/;
     push @ret, \%line;
   }
@@ -641,8 +640,8 @@ sub rev_info {
   return unless $self->valid_rev($rev);
 
   return $self->list_revs(
-      rev => $rev, count => 1,
-      ( $project ? (project => $project) : () )
+         rev => $rev, count => 1,
+         ( $project ? (project => $project) : () )
   );
 }
 
@@ -736,11 +735,11 @@ For a given sha1 check which branches currently point at it.
 =cut
 
 sub refs_for {
-    my($self, $sha1) = @_;
+       my($self, $sha1) = @_;
 
-    my $refs = $self->references->{$sha1};
+       my $refs = $self->references->{$sha1};
 
-    return $refs ? @$refs : ();
+       return $refs ? @$refs : ();
 }
 
 =head2 references
@@ -751,23 +750,23 @@ C<git_get_references>.
 =cut
 
 sub references {
-    my($self) = @_;
+       my($self) = @_;
 
-    return $self->{references}
-        if $self->{references};
+       return $self->{references}
+               if $self->{references};
 
-    # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
-    # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
-    my @reflist = $self->command(qw(show-ref --dereference))
-        or return;
+       # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
+       # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
+       my @reflist = $self->command(qw(show-ref --dereference))
+               or return;
 
-    my %refs;
-    for(@reflist) {
-        push @{$refs{$1}}, $2
-            if m!^($SHA1RE)\srefs/(.*)$!;
-    }
+       my %refs;
+       for(@reflist) {
+               push @{$refs{$1}}, $2
+                       if m!^($SHA1RE)\srefs/(.*)$!;
+       }
 
-    return $self->{references} = \%refs;
+       return $self->{references} = \%refs;
 }
 
 1;
index a2c93df..869e0ee 100644 (file)
@@ -1,4 +1,4 @@
-<link rel="stylesheet" type="text/css" href="/static/css/syntax/[% language %].css"/>
+<link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/css/syntax/' + language + '.css') %]"/>
 [% FOREACH item IN diff %]
 <div class='diff-head'>
  diff --git
index 74971a1..8e3ce99 100644 (file)
   [% IF baseurl %]
   <base href="[% baseurl %]" />
   [% END %]
-  <link rel="stylesheet" href="/static/css/blueprint/screen.css" type="text/css" media="screen, projection">
-  <link rel="stylesheet" href="/static/css/blueprint/print.css" type="text/css" media="print">
+  <link rel="stylesheet" href="[% c.uri_for('/static/css/blueprint/screen.css') %]" type="text/css" media="screen, projection">
+  <link rel="stylesheet" href="[% c.uri_for('/static/css/blueprint/print.css') %]" type="text/css" media="print">
   <!--[if lt IE 8]>
-    <link rel="stylesheet" href="/static/css/blueprint/ie.css" type="text/css" media="screen, projection">
+    <link rel="stylesheet" href="[% c.uri_for('/static/css/blueprint/ie.css') %]" type="text/css" media="screen, projection">
   <![endif]-->  
-  <link rel="stylesheet" type="text/css" href="/static/css/site.css"/>
-  <link rel="stylesheet" type="text/css" href="[% stylesheet %]"/>
+  <link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/css/site.css') %]"/>
+  [% IF stylesheet %]<link rel="stylesheet" type="text/css" href="[% stylesheet %]"/>[% END %]
   [% FOR link IN links %]
             <link rel="[% link.rel %]"
                   title="[% link.title %]"
index 9b93bf7..93ec59e 100644 (file)
@@ -27,8 +27,8 @@
     USE Cycle('dark', 'light');
     FOR p IN projects %]
     <tr class="[% Cycle.next %]">
-        <td><a class="list" href="[% c.uri_for('/summary')%]?p=[% p.name %]">[% p.name %]</a></td>
-        <td><a class="list" title="[% p.description %]" href="[% c.uri_for('/summary') %]?p=[% p.name %]">[% p.description.substr(0, 20) %]</a></td>
+        <td><a class="list" href="[% c.uri_for('/summary', { 'p' => p.name } ) %]">[% p.name %]</a></td>
+        <td><a class="list" title="[% p.description %]" href="[% c.uri_for('/summary', { 'p' => p.name } ) %]">[% p.description.substr(0, 20) %]</a></td>
         <td>[% p.owner %]</td>
         <td class="age2">[% p.last_change %]</td>
         <td class="link"><a href="[% c.uri_for("summary") %]">summary</a>
diff --git a/t/02pod.t b/t/02pod.t
deleted file mode 100644 (file)
index 3d1bab1..0000000
--- a/t/02pod.t
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => 'Test::Pod 1.14 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_files_ok();
diff --git a/t/03podcoverage.t b/t/03podcoverage.t
deleted file mode 100644 (file)
index 4e1c6e7..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Test::More;
-
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_coverage_ok();
diff --git a/t/author/notabs.t b/t/author/notabs.t
new file mode 100644 (file)
index 0000000..5f3efe8
--- /dev/null
@@ -0,0 +1,3 @@
+use Test::NoTabs;
+all_perl_files_ok;
+
diff --git a/t/author/pod.t b/t/author/pod.t
new file mode 100644 (file)
index 0000000..3c6d16f
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Test::Pod 1.14;
+
+all_pod_files_ok();
diff --git a/t/author/podcoverage.t b/t/author/podcoverage.t
new file mode 100644 (file)
index 0000000..3abc25e
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Test::Pod::Coverage 1.04;
+
+all_pod_coverage_ok();