Bump version to 0.004002 and update Changes.
[catagits/Gitalist.git] / lib / Gitalist / Git / Util.pm
index 4ce5bb3..9638b8c 100644 (file)
@@ -3,15 +3,16 @@ use MooseX::Declare;
 class Gitalist::Git::Util {
     use File::Which;
     use Git::PurePerl;
-    use IPC::Run qw(run);
+    use IPC::Run qw(run start);
+    use Symbol qw(geniosym);
     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
 
-    has project => (
-        isa => 'Gitalist::Git::Project',
+    has repository => (
+        isa => 'Gitalist::Git::Repository',
         handles => { gitdir => 'path' },
         is => 'bare', # No accessor
         weak_ref => 1, # Weak, you have to hold onto me.
-        predicate => 'has_project',
+        predicate => 'has_repository',
     );
     has _git      => ( isa => NonEmptySimpleStr, is => 'ro', lazy_build => 1 );
     sub _build__git {
@@ -31,15 +32,15 @@ EOR
         isa => 'Git::PurePerl', is => 'ro', lazy => 1,
         default => sub {
             my $self = shift;
-            confess("Cannot get gpp without project")
-                unless $self->has_project;
+            confess("Cannot get gpp without repository")
+                unless $self->has_repository;
             Git::PurePerl->new(gitdir => $self->gitdir);
         },
     );
 
     method run_cmd (@args) {
         unshift @args, ( '--git-dir' => $self->gitdir )
-            if $self->has_project;
+            if $self->has_repository;
 #        print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
         run [$self->_git, @args], \my($in, $out, $err);
 
@@ -47,14 +48,16 @@ EOR
     }
 
     method run_cmd_fh (@args) {
+        my ($in, $out, $err) = (geniosym, geniosym, geniosym);
         unshift @args, ('--git-dir' => $self->gitdir)
-            if $self->has_project;
-        run [$self->_git, @args],
-            '<pipe', \*IN,
-            '>pipe', \*OUT,
-            '2>pipe', \*ERR
+            if $self->has_repository;
+#        print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
+        start [$self->_git, @args],
+            '<pipe', $in,
+            '>pipe', $out,
+            '2>pipe', $err
                 or die "cmd returned *?";
-        return \*OUT;
+        return $out;
     }
 
     method run_cmd_list (@args) {
@@ -67,3 +70,24 @@ EOR
     }
 
 } # end class
+
+__END__
+
+=head1 NAME
+
+Gitalist::Git::Util - Class for utilities to run git or deal with Git::PurePerl
+
+=head1 SEE ALSO
+
+L<Git::PurePerl>.
+
+=head1 AUTHORS
+
+See L<Gitalist> for authors.
+
+=head1 LICENSE
+
+See L<Gitalist> for the license.
+
+=cut
+