Fixed bug in where branch links were always pointing at master.
Dan Brook [Thu, 12 Nov 2009 11:21:47 +0000 (11:21 +0000)]
Tidied up Makefile.PL.
Switched from pipe open to IPC::Run (for win32 & future goodness).

Makefile.PL
lib/Gitalist/Git/Util.pm
root/_heads.tt2
t/02git_project.t

index ee268f1..446cace 100644 (file)
@@ -1,9 +1,10 @@
 #!/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::AutoInstall;
 use Module::Install::AuthorRequires;
 use Module::Install::AuthorTests;
 use Module::Install::ReadmeFromPod;
@@ -17,31 +18,38 @@ requires 'Catalyst::Plugin::ConfigLoader';
 requires 'Catalyst::Plugin::StackTrace';
 requires 'Catalyst::Plugin::Static::Simple';
 requires 'Catalyst::Action::RenderView';
-requires 'Catalyst::View::ContentNegotiation::XHTML';
+
+requires 'Template';
+requires 'Template::Provider::Encoding';
+requires 'Catalyst::View::TT';
 requires 'Template::Plugin::Cycle';
+
+requires 'Config::General';
+
 requires 'Moose';
-requires 'namespace::autoclean';
-requires 'Config::General'; # This should reflect the config file format you've chosen
-                 # See Catalyst::Plugin::ConfigLoader for supported formats
+requires 'Moose::Autobox';
+requires 'MooseX::Declare';
 requires 'MooseX::Types::Common';
 requires 'MooseX::Types::Path::Class';
 requires 'MooseX::Types';
-requires 'File::Find::Rule';
-requires 'File::Stat::ModeString';
-requires 'DateTime::Format::Mail';
-requires 'IO::Capture::Stdout';
-requires 'File::Which';
+requires 'namespace::autoclean';
+
+requires 'Git::PurePerl'; # Note - need the git version in broquaint's fork
+
 requires 'aliased';
 requires 'CGI';
 requires 'DateTime';
-requires 'Git::PurePerl'; # Note - need the git version in broquaint's fork
+requires 'DateTime::Format::Mail';
+requires 'File::Copy::Recursive';
+requires 'File::Stat::ModeString';
+requires 'File::Which';
+requires 'HTML::Entities';
+requires 'IO::Capture::Stdout';
+requires 'IPC::Run';
 requires 'List::MoreUtils';
-requires 'MooseX::Declare';
 requires 'Path::Class' => '0.17';
 requires 'Sub::Exporter';
 requires 'Syntax::Highlight::Engine::Kate';
-requires 'Moose::Autobox';
-requires 'DateTime::Format::Human::Duration';
 
 author_requires 'Test::NoTabs';
 author_requires 'Test::Pod' => '1.14';
index 8564cb0..a7865b7 100644 (file)
@@ -3,7 +3,9 @@ use MooseX::Declare;
 class Gitalist::Git::Util {
     use File::Which;
     use Git::PurePerl;
+    use IPC::Run qw(run);
     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
+
     has project => (
         isa => 'Gitalist::Git::Project',
         handles => { gitdir => 'path' },
@@ -38,16 +40,10 @@ EOR
     method run_cmd (@args) {
         unshift @args, ( '--git-dir' => $self->gitdir )
             if $self->has_project;
-#        print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
-
-        open my $fh, '-|', $self->_git, @args
-            or die "failed to run git command";
-        binmode $fh, ':encoding(UTF-8)';
 
-        my $output = do { local $/ = undef; <$fh> };
-        close $fh;
+        run [$self->_git, @args], \my($in, $out, $err);
 
-        return $output;
+        return $out;
     }
 
     method get_gpp_object (NonEmptySimpleStr $sha1) {
index c2b2fd6..0a1c45b 100644 (file)
@@ -23,9 +23,9 @@
    <td class='time-since'>[% time_since(head.last_change) %]</td>
    <td class='head[% head.sha1 == HEAD ? ' current' : '' %]'>[% head.name %]</td>
    <td class='action-list'>
-     <a href="[% c.uri_for("shortlog", {h='refs/head/' _ head.name}) %]">shortlog</a>
-     <a href="[% c.uri_for("log", {h='refs/head/' _ head.name}) %]">log</a>
-     <a href="[% c.uri_for("tree", {h='refs/head/' _ head.name, hb=head.name}) %]">tree</a>
+     <a href="[% c.uri_for("shortlog", {h='refs/heads/' _ head.name}) %]">shortlog</a>
+     <a href="[% c.uri_for("log", {h='refs/heads/' _ head.name}) %]">log</a>
+     <a href="[% c.uri_for("tree", {h='refs/heads/' _ head.name, hb=head.name}) %]">tree</a>
    </td>
   </tr>
  [% END %]
index 9472a9e..acd2e04 100644 (file)
@@ -25,7 +25,9 @@ is($proj->info->{name}, qw/repo1/, 'repo name in info hash');
 
 ok($proj->heads, '->heads returns stuff');
      
-is($proj->head_hash, qw/36c6c6708b8360d7023e8a1649c45bcf9b3bd818/, 'head_hash for HEAD is correct');
+is($proj->head_hash, '36c6c6708b8360d7023e8a1649c45bcf9b3bd818', 'head_hash for HEAD is correct');
+is($proj->head_hash('refs/heads/master'), '36c6c6708b8360d7023e8a1649c45bcf9b3bd818', 'head_hash for refs/heads/master is correct');
+is($proj->head_hash('rafs/head/mister'), undef, 'head_hash for rafs/head/mister is undef');
 
 is(scalar $proj->list_tree, 2, 'expected number of entries in tree');
 isa_ok(($proj->list_tree)[1], 'Gitalist::Git::Object');