| 1 | package Git::LowLevel; | ||||||||||
| 2 | # ABSTRACT: LowLevel Blob/Tree/Commit operations on a GIT Repository | ||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use MooseX::Privacy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Git::LowLevel::Reference; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 4 | has 'git_dir' => (is => 'ro', isa => 'Str', required => 1); | |||||||||
| 12 | |||||||||||
| 13 | 4 | has 'gitcmd' => (is => 'rw', isa=>'Str', default=>'git'); | |||||||||
| 14 | |||||||||||
| 15 | 4 | has 'bare' => (is => 'rw', default=>0, traits => [qw/Private/]); | |||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | 9 | ▶ | private_method _isGit => sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.4
| |||||||||||
| 21 | 9 | my $self = shift; | |||||||||
| 22 | |||||||||||
| 23 | 9 | ▶ | return 0 unless -d $self->git_dir(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 9 | ▶ | if (-d $self->git_dir . "/.git") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | { | ||||||||||
| 27 | 8 | $self->bare(0); | |||||||||
| 28 | 8 | return 1; | |||||||||
| 29 | } | ||||||||||
| 30 | 1 | my $help=readpipe("cd " . $self->git_dir . "; " . $self->gitcmd() . ' rev-parse --git-dir 1>/dev/null 2> /dev/null;echo $?'); | |||||||||
| 31 | 1 | chomp($help); | |||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | if ($help == 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | { | ||||||||||
| 35 | 0 | $self->bare(1); | |||||||||
| 36 | 0 | return 1; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 1 | return 0; | |||||||||
| 40 | 4 | }; | |||||||||
| 41 | |||||||||||
| 42 | 9 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 43 | 9 | my $self = shift; | |||||||||
| 44 | |||||||||||
| 45 | 9 | ▶ | die("directory does not exist (".$self->git_dir . " )") unless -d $self->git_dir(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 9 | ▶ | die("directory is not a git repository (" .$self->git_dir . " )") unless $self->_isGit(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | #update gitcmd attribute | ||||||||||
| 49 | 8 | $self->gitcmd($self->gitcmd . ' --git-dir='.$self->git_dir()); | |||||||||
| 50 | 8 | ▶ | if ($self->bare()==0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | { | ||||||||||
| 52 | 8 | $self->gitcmd($self->gitcmd . "/.git"); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | }; | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | sub getReference | ||||||||||
| 59 | 7 | ▶ | { | ||||||||
|
Subroutine
getReference: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 60 | 7 | my $self = shift; | |||||||||
| 61 | 7 | my $ref = shift; | |||||||||
| 62 | |||||||||||
| 63 | 7 | return Git::LowLevel::Reference->new(repository=>$self, reference=>$ref); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 4 | 1; | |||||||||
| 69 | |||||||||||
| 70 | __END__ | ||||||||||