| 1 | package Git::LowLevel::Blob; | ||||||||||||||||||||||||||||
| 2 | #ABSTRACT: class representing a GIT Blow Object | ||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use MooseX::Privacy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | has 'repository' => (is => 'ro', isa => 'Git::LowLevel', required => 1); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | has 'hash' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | has 'path' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | has 'parent' => (is => 'rw', isa => 'Git::LowLevel::Tree'); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | has '_content' => (is =>'rw'); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub timestamp_added | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
timestamp_added: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 23 | 0 | my $help = readpipe($self->repository->gitcmd() . " log --follow --diff-filter=A --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null"); | |||||||||||||||||||||||||||
| 24 | 0 | my @lines = split /\n/,$help; | |||||||||||||||||||||||||||
| 25 | 0 | for my $line (@lines) | |||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 0 | return $1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | return $help; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub timestamp_last | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
timestamp_last: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | 0 | my $help = readpipe($self->repository->gitcmd() . " log --follow --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null"); | |||||||||||||||||||||||||||
| 40 | 0 | my @lines = split /\n/,$help; | |||||||||||||||||||||||||||
| 41 | 0 | for my $line (@lines) | |||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($line =~ /^Date:\s+(\d+)\s([+-]\d+)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||
| 45 | 0 | return $1; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | return $help; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub committer | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
committer: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 55 | 0 | my $help = readpipe($self->repository->gitcmd() . " log --follow --date=raw " . $self->reference->reference . " -- \"" . $self->path . "\" 2>/dev/null"); | |||||||||||||||||||||||||||
| 56 | 0 | my @lines = split /\n/,$help; | |||||||||||||||||||||||||||
| 57 | 0 | for my $line (@lines) | |||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($line =~ /^Author:\s(.*)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||
| 61 | 0 | return $1; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | return $help; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | sub mypath | ||||||||||||||||||||||||||||
| 69 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mypath: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | 5 | my $path = fileparse($self->path); | |||||||||||||||||||||||||||
| 72 | 5 | ▶ | if (!defined($path) || length($path)==0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $path or length $path == 0
MC/DC0%0/2
not defined $path or length $path == 0
not defined $path
length $path == 0
Truth table33%1/3
not(A) or B
A= not defined $pathB= length $path == 0
| |||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||
| 74 | 0 | $path = $self->path; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 5 | $path=~s/\///g; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 5 | return $path; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | sub content | ||||||||||||||||||||||||||||
| 85 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
content: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | my $help = readpipe($self->repository->gitcmd() . " cat-file blob " . $self->hash); | |||||||||||||||||||||||||||
| 89 | 2 | chomp($help); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 2 | $self->_content($help); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 2 | return $help; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | sub save | ||||||||||||||||||||||||||||
| 98 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
save: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 3 | ▶ | return unless defined($self->_content()) && length($self->_content)>0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->_content and length $self->_content > 0
MC/DC0%0/2
defined $self->_content and length $self->_content > 0
defined $self->_content
length $self->_content > 0
Truth table33%1/3
A and B
A= defined $self->_contentB= length $self->_content > 0
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | #TODO: perhaps do not use stdin ... better for binary files | ||||||||||||||||||||||||||||
| 104 | 3 | my $help = readpipe("echo \'".$self->_content."\' |" . $self->repository->gitcmd() . " hash-object -w --stdin "); | |||||||||||||||||||||||||||
| 105 | 3 | chomp($help); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 3 | $self->hash($help); | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub treeEntry | ||||||||||||||||||||||||||||
| 112 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
treeEntry: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 3 | ▶ | if (defined($self->hash) && length($self->hash)>30 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->hash and length $self->hash > 30
MC/DC0%0/2
defined $self->hash and length $self->hash > 30
defined $self->hash
length $self->hash > 30
Truth table33%1/3
A and B
A= defined $self->hashB= length $self->hash > 30
| |||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||
| 117 | 3 | return "100644 blob " . $self->hash . "\t" . $self->mypath . "\n"; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | return ""; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub find | ||||||||||||||||||||||||||||
| 124 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 2 | my $path = shift; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 2 | ▶ | return $self unless $self->mypath ne $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | return; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | sub del | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
del: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | $self->_content(""); | |||||||||||||||||||||||||||
| 138 | 0 | $self->hash(" "); | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 4 | 1; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||