App-GitGot

 view release on metacpan or  search on metacpan

lib/App/GitGot/Repo/Git.pm  view on Meta::CPAN

package App::GitGot::Repo::Git;
our $AUTHORITY = 'cpan:GENEHACK';
$App::GitGot::Repo::Git::VERSION = '1.339';
# ABSTRACT: Git repo objects
use 5.014;

use Git::Wrapper;
use Test::MockObject;
use Try::Tiny;
use Types::Standard -types;

use App::GitGot::Types qw/ GitWrapper /;

use Moo;
extends 'App::GitGot::Repo';
use namespace::autoclean;

has '+type' => ( default => 'git' );

has '_wrapper' => (
  is         => 'lazy' ,
  isa        => GitWrapper ,
  handles    => [ qw/
                      checkout
                      cherry
                      clone
                      config
                      fetch
                      gc
                      pull
                      push
                      remote
                      status
                      symbolic_ref
                    / ] ,
);

sub _build__wrapper {
  my $self = shift;

  # for testing...
  if ( $ENV{GITGOT_FAKE_GIT_WRAPPER} ) {
    my $mock = Test::MockObject->new;
    $mock->set_isa( 'Git::Wrapper' );
    foreach my $method ( qw/ cherry clone fetch gc pull
                             remote symbolic_ref / ) {
      $mock->mock( $method => sub { return( '1' )});
    }
    $mock->mock( 'checkout' => sub { } );
    $mock->mock( 'status' => sub { package
                                     MyFake; sub get { return () }; return bless {} , 'MyFake' } );
    $mock->mock( 'config' => sub { 0 });
    $mock->mock( 'ERR'    => sub { [ ] });

    return $mock
  }
  else {
    return Git::Wrapper->new( $self->path )
      || die "Can't make Git::Wrapper";
  }
}



sub current_branch {
  my $self = shift;

  my $branch;



( run in 3.912 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )