| 1 | package Git::PurePerl; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use MooseX::Types::Path::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Compress::Zlib qw(uncompress); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Data::Stream::Bulk; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Data::Stream::Bulk::Array; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Data::Stream::Bulk::Path::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use File::Find::Rule; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Git::PurePerl::Actor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Git::PurePerl::Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Git::PurePerl::DirectoryEntry; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Git::PurePerl::Loose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Git::PurePerl::Object; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Git::PurePerl::NewDirectoryEntry; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Git::PurePerl::NewObject; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Git::PurePerl::NewObject::Blob; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Git::PurePerl::NewObject::Commit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Git::PurePerl::NewObject::Tag; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use Git::PurePerl::NewObject::Tree; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use Git::PurePerl::Object::Tree; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use Git::PurePerl::Object::Blob; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Git::PurePerl::Object::Commit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use Git::PurePerl::Object::Tag; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Git::PurePerl::Object::Tree; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use Git::PurePerl::Pack; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use Git::PurePerl::Pack::WithIndex; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use Git::PurePerl::Pack::WithoutIndex; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use Git::PurePerl::PackIndex; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use Git::PurePerl::PackIndex::Version1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use Git::PurePerl::PackIndex::Version2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use Git::PurePerl::Protocol; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | use IO::Digest; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | use Path::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | our $VERSION = '0.53'; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | has 'directory' => ( | |||||||||||||||||||||||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | isa => 'Path::Class::Dir', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | coerce => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | has 'gitdir' => ( | |||||||||||||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | isa => 'Path::Class::Dir', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | coerce => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | has 'loose' => ( | |||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | isa => 'Git::PurePerl::Loose', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | has 'packs' => ( | |||||||||||||||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | isa => 'ArrayRef[Git::PurePerl::Pack]', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | auto_deref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | has 'description' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 73 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 74 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | file( $self->gitdir, 'description' )->slurp( chomp => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | has 'config' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | isa => 'Git::PurePerl::Config', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | Git::PurePerl::Config->new(git => $self); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | my $params = $class->SUPER::BUILDARGS(@_); | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 9 | ▶ | $params->{'gitdir'} ||= dir( $params->{'directory'}, '.git' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$params->{"gitdir"} ||= dir($params->{"directory"}, ".git")
MC/DC0%0/2
$params->{"gitdir"} ||= dir($params->{"directory"}, ".git")
$params->{"gitdir"}
dir($params->{"directory"}, ".git")
Truth table66%2/3
A ||= B
A= $params->{"gitdir"}B= dir($params->{"directory"}, ".git")
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 9 | return $params; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 9 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 9 | ▶ | unless ( -d $self->gitdir ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | confess $self->gitdir . ' is not a directory'; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | ▶ | unless ( not defined $self->directory or -d $self->directory ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->directory or -d $self->directory
MC/DC0%0/2
not defined $self->directory or -d $self->directory
not defined $self->directory
-d $self->directory
Truth table66%2/3
not(A) or B
A= not defined $self->directoryB= -d $self->directory
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | confess $self->directory . ' is not a directory'; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | ▶ | sub _build_loose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_loose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | my $loose_dir = dir( $self->gitdir, 'objects' ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | return Git::PurePerl::Loose->new( directory => $loose_dir ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | ▶ | sub _build_packs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_packs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | my $pack_dir = dir( $self->gitdir, 'objects', 'pack' ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 8 | my @packs; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 8 | foreach my $filename ( $pack_dir->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | next unless $filename =~ /\.pack$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | push @packs, | |||||||||||||||||||||||||||||||||||||||||
| 126 | Git::PurePerl::Pack::WithIndex->new( filename => $filename ); | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 8 | return \@packs; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 22 | ▶ | sub _ref_names_recursive { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ref_names_recursive: called CC=3 SCAR=13.3
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 22 | my ( $dir, $base, $names ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 22 | foreach my $file ( $dir->children ) { | |||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | if ( -d $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $reldir = $file->relative($dir); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $subbase = $base . $reldir . "/"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | _ref_names_recursive( $file, $subbase, $names ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | push @$names, $base . $file->basename; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 11 | ▶ | sub ref_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ref_names: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 11 | my @names; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 11 | foreach my $type (qw(heads remotes tags)) { | |||||||||||||||||||||||||||||||||||||||||
| 149 | 33 | my $dir = dir( $self->gitdir, 'refs', $type ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 33 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 22 | my $base = "refs/$type/"; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 22 | _ref_names_recursive( $dir, $base, \@names ); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 11 | my $packed_refs = file( $self->gitdir, 'packed-refs' ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 11 | ▶ | if ( -f $packed_refs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | foreach my $line ( $packed_refs->slurp( chomp => 1 ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 157 | 12 | ▶ | next if $line =~ /^#/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 6 | ▶ | next if $line =~ /^\^/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | my ( $sha1, $name ) = split ' ', $line; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 6 | push @names, $name; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | return @names; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | sub refs_sha1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refs_sha1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | return map { $self->ref_sha1($_) } $self->ref_names; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | ▶ | sub refs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | return map { $self->ref($_) } $self->ref_names; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 30 | ▶ | sub ref_sha1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ref_sha1: called CC=15 SCAR=32.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 30 | my ( $self, $wantref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 30 | my $dir = dir( $self->gitdir, 'refs' ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 30 | ▶ | return unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 30 | ▶ | if ($wantref eq "HEAD") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $file = file($self->gitdir, 'HEAD'); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $sha1 = file($file)->slurp | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
file($file)->slurp || confess("Error reading ${file}: $!")
MC/DC0%0/1
file($file)->slurp || confess("Error reading ${file}: $!")
file($file)->slurp
Truth table0%0/2
A
A= file($file)->slurp
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | || confess("Error reading $file: $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | chomp $sha1; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return _ensure_sha1_is_sha1( $self, $sha1 ); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 30 | foreach my $file ( File::Find::Rule->new->file->in($dir) ) { | |||||||||||||||||||||||||||||||||||||||||
| 190 | 16 | my $ref = 'refs/' . file($file)->relative($dir)->as_foreign('Unix'); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 16 | ▶ | if ( $ref eq $wantref ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 16 | ▶ | my $sha1 = file($file)->slurp | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
file($file)->slurp || confess("Error reading ${file}: $!")
MC/DC0%0/1
file($file)->slurp || confess("Error reading ${file}: $!")
file($file)->slurp
Truth table50%1/2
A
A= file($file)->slurp
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | || confess("Error reading $file: $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 16 | chomp $sha1; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | return _ensure_sha1_is_sha1( $self, $sha1 ); | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | my $packed_refs = file( $self->gitdir, 'packed-refs' ); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | if ( -f $packed_refs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 14 | my $last_name; | |||||||||||||||||||||||||||||||||||||||||
| 202 | my $last_sha1; | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 14 | foreach my $line ( $packed_refs->slurp( chomp => 1 ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 204 | 28 | ▶ | next if $line =~ /^#/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 14 | my ( $sha1, $name ) = split ' ', $line; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 14 | $sha1 =~ s/^\^//; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 14 | ▶ | $name ||= $last_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $last_name
MC/DC0%0/2
$name ||= $last_name
$name
$last_name
Truth table33%1/3
A ||= B
A= $nameB= $last_name
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 14 | ▶ | return _ensure_sha1_is_sha1( $self, $last_sha1 ) if $last_name and $last_name eq $wantref and $name ne $wantref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$last_name and $last_name eq $wantref and $name ne $wantref
$last_name and $last_name eq $wantref
MC/DC0%0/3
$last_name and $last_name eq $wantref and $name ne $wantref
$last_name
$last_name eq $wantref
$name ne $wantref
Truth table25%1/4
A and B and C
A= $last_nameB= $last_name eq $wantrefC= $name ne $wantref
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 14 | $last_name = $name; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 14 | $last_sha1 = $sha1; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 14 | ▶ | return _ensure_sha1_is_sha1( $self, $last_sha1 ) if $last_name eq $wantref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 30 | ▶ | sub _ensure_sha1_is_sha1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure_sha1_is_sha1: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 30 | my ( $self, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 30 | ▶ | return $self->ref_sha1($1) if $sha1 =~ /^ref: (.*)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 30 | return $sha1; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 21 | ▶ | sub ref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 21 | my ( $self, $wantref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 21 | return $self->get_object( $self->ref_sha1($wantref) ); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | ▶ | sub master_sha1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
master_sha1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | return $self->ref_sha1('refs/heads/master'); | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 9 | ▶ | sub master { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
master: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 9 | return $self->ref('refs/heads/master'); | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub head_sha1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head_sha1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return $self->ref_sha1('HEAD'); | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub head { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return $self->ref('HEAD'); | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 117 | ▶ | sub get_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 117 | my ( $self, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 117 | ▶ | return unless $sha1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 114 | ▶ | return $self->get_object_packed($sha1) || $self->get_object_loose($sha1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->get_object_packed($sha1) || $self->get_object_loose($sha1)
MC/DC0%0/2
$self->get_object_packed($sha1) || $self->get_object_loose($sha1)
$self->get_object_packed($sha1)
$self->get_object_loose($sha1)
Truth table66%2/3
A || B
A= $self->get_object_packed($sha1)B= $self->get_object_loose($sha1)
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 9 | ▶ | sub get_objects { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_objects: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 9 | my ( $self, @sha1s ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 9 | return map { $self->get_object($_) } @sha1s; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 114 | ▶ | sub get_object_packed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object_packed: called CC=5 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 114 | my ( $self, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 114 | foreach my $pack ( $self->packs ) { | |||||||||||||||||||||||||||||||||||||||||
| 265 | 46 | my ( $kind, $size, $content ) = $pack->get_object($sha1); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 46 | ▶ | if ( defined($kind) && defined($size) && defined($content) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $kind and defined $size and defined $content
defined $kind and defined $size
MC/DC0%0/3
defined $kind and defined $size and defined $content
defined $kind
defined $size
defined $content
Truth table25%1/4
A and B and C
A= defined $kindB= defined $sizeC= defined $content
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 46 | return $self->create_object( $sha1, $kind, $size, $content ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 68 | ▶ | sub get_object_loose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object_loose: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 68 | my ( $self, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 68 | my ( $kind, $size, $content ) = $self->loose->get_object($sha1); | |||||||||||||||||||||||||||||||||||||||||
| 276 | 68 | ▶ | if ( defined($kind) && defined($size) && defined($content) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $kind and defined $size and defined $content
defined $kind and defined $size
MC/DC0%0/3
defined $kind and defined $size and defined $content
defined $kind
defined $size
defined $content
Truth table25%1/4
A and B and C
A= defined $kindB= defined $sizeC= defined $content
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 68 | return $self->create_object( $sha1, $kind, $size, $content ); | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 114 | ▶ | sub create_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_object: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 114 | my ( $self, $sha1, $kind, $size, $content ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 114 | ▶ | if ( $kind eq 'commit' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 47 | return Git::PurePerl::Object::Commit->new( | |||||||||||||||||||||||||||||||||||||||||
| 285 | sha1 => $sha1, | ||||||||||||||||||||||||||||||||||||||||||
| 286 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 289 | git => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } elsif ( $kind eq 'tree' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 30 | return Git::PurePerl::Object::Tree->new( | |||||||||||||||||||||||||||||||||||||||||
| 293 | sha1 => $sha1, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | git => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } elsif ( $kind eq 'blob' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 37 | return Git::PurePerl::Object::Blob->new( | |||||||||||||||||||||||||||||||||||||||||
| 301 | sha1 => $sha1, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | git => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } elsif ( $kind eq 'tag' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return Git::PurePerl::Object::Tag->new( | |||||||||||||||||||||||||||||||||||||||||
| 309 | sha1 => $sha1, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | kind => $kind, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | git => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | confess "unknown kind $kind: $content"; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 18 | ▶ | sub all_sha1s { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_sha1s: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 18 | my $dir = dir( $self->gitdir, 'objects' ); | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 18 | my @streams; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 18 | push @streams, $self->loose->all_sha1s; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 18 | foreach my $pack ( $self->packs ) { | |||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | push @streams, $pack->all_sha1s; | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 18 | return Data::Stream::Bulk::Cat->new( streams => \@streams ); | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 9 | ▶ | sub all_objects { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_objects: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 9 | my $stream = $self->all_sha1s; | |||||||||||||||||||||||||||||||||||||||||
| 337 | return Data::Stream::Bulk::Filter->new( | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 9 | ▶ | filter => sub { return [ $self->get_objects(@$_) ] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 9 | stream => $stream, | |||||||||||||||||||||||||||||||||||||||||
| 340 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | ▶ | sub put_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put_object: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 14 | my ( $self, $object, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 14 | $self->loose->put_object($object); | |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 14 | ▶ | if ( $object->kind eq 'commit' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | ▶ | $ref = 'master' unless $ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 4 | $self->update_ref( $ref, $object->sha1 ); | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 4 | ▶ | sub update_ref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_ref: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | my ( $self, $refname, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 4 | my $ref = file( $self->gitdir, 'refs', 'heads', $refname ); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 4 | $ref->parent->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | my $ref_fh = $ref->openw; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 4 | ▶ | $ref_fh->print($sha1) || die "Error writing to $ref"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | # FIXME is this always what we want? | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | my $head = file( $self->gitdir, 'HEAD' ); | |||||||||||||||||||||||||||||||||||||||||
| 362 | 4 | my $head_fh = $head->openw; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | ▶ | $head_fh->print("ref: refs/heads/$refname") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | || die "Error writing to $head"; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | my ( $class, %arguments ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | my $directory = $arguments{directory}; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | my $git_dir; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 3 | ▶ | unless ( defined $directory ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | $git_dir = $arguments{gitdir} | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | || confess | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arguments{'gitdir'} || confess(q[init() needs either a 'directory' or a 'gitdir' argument])
MC/DC0%0/1
$arguments{'gitdir'} || confess(q[init() needs either a 'directory' or a 'gitdir' argument])
$arguments{'gitdir'}
Truth table50%1/2
A
A= $arguments{'gitdir'}
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | "init() needs either a 'directory' or a 'gitdir' argument"; | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | if ( not defined $arguments{gitdir} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | $git_dir = $arguments{gitdir} = dir( $directory, '.git' ); | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | dir($directory)->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 3 | dir($git_dir)->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 3 | dir( $git_dir, 'refs', 'tags' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | dir( $git_dir, 'objects', 'info' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | dir( $git_dir, 'objects', 'pack' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | dir( $git_dir, 'branches' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | dir( $git_dir, 'hooks' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | ▶ | my $bare = defined($directory) ? 'false' : 'true'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | $class->_add_file( | |||||||||||||||||||||||||||||||||||||||||
| 393 | file( $git_dir, 'config' ), | ||||||||||||||||||||||||||||||||||||||||||
| 394 | "[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = $bare\n\tlogallrefupdates = true\n" | ||||||||||||||||||||||||||||||||||||||||||
| 395 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | $class->_add_file( file( $git_dir, 'description' ), | |||||||||||||||||||||||||||||||||||||||||
| 397 | "Unnamed repository; edit this file to name it for gitweb.\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | $class->_add_file( | |||||||||||||||||||||||||||||||||||||||||
| 399 | file( $git_dir, 'hooks', 'applypatch-msg' ), | ||||||||||||||||||||||||||||||||||||||||||
| 400 | "# add shell script and make executable to enable\n" | ||||||||||||||||||||||||||||||||||||||||||
| 401 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | $class->_add_file( file( $git_dir, 'hooks', 'post-commit' ), | |||||||||||||||||||||||||||||||||||||||||
| 403 | "# add shell script and make executable to enable\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | $class->_add_file( | |||||||||||||||||||||||||||||||||||||||||
| 405 | file( $git_dir, 'hooks', 'post-receive' ), | ||||||||||||||||||||||||||||||||||||||||||
| 406 | "# add shell script and make executable to enable\n" | ||||||||||||||||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 3 | $class->_add_file( file( $git_dir, 'hooks', 'post-update' ), | |||||||||||||||||||||||||||||||||||||||||
| 409 | "# add shell script and make executable to enable\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | $class->_add_file( | |||||||||||||||||||||||||||||||||||||||||
| 411 | file( $git_dir, 'hooks', 'pre-applypatch' ), | ||||||||||||||||||||||||||||||||||||||||||
| 412 | "# add shell script and make executable to enable\n" | ||||||||||||||||||||||||||||||||||||||||||
| 413 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | $class->_add_file( file( $git_dir, 'hooks', 'pre-commit' ), | |||||||||||||||||||||||||||||||||||||||||
| 415 | "# add shell script and make executable to enable\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | $class->_add_file( file( $git_dir, 'hooks', 'pre-rebase' ), | |||||||||||||||||||||||||||||||||||||||||
| 417 | "# add shell script and make executable to enable\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | $class->_add_file( file( $git_dir, 'hooks', 'update' ), | |||||||||||||||||||||||||||||||||||||||||
| 419 | "# add shell script and make executable to enable\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | dir( $git_dir, 'info' )->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 3 | $class->_add_file( file( $git_dir, 'info', 'exclude' ), | |||||||||||||||||||||||||||||||||||||||||
| 423 | "# *.[oa]\n# *~\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | return $class->new(%arguments); | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 4 | ▶ | sub checkout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkout: called CC=8 SCAR=25.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 4 | my ( $self, $directory, $tree ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 4 | ▶ | $directory ||= $self->directory; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$directory ||= $self->directory
MC/DC0%0/2
$directory ||= $self->directory
$directory
$self->directory
Truth table33%1/3
A ||= B
A= $directoryB= $self->directory
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 4 | ▶ | $tree ||= $self->master->tree; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$tree ||= $self->master->tree
MC/DC0%0/2
$tree ||= $self->master->tree
$tree
$self->master->tree
Truth table33%1/3
A ||= B
A= $treeB= $self->master->tree
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 4 | ▶ | confess("Missing tree") unless $tree; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | foreach my $directory_entry ( $tree->directory_entries ) { | |||||||||||||||||||||||||||||||||||||||||
| 434 | 5 | my $filename = file( $directory, $directory_entry->filename ); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 5 | my $sha1 = $directory_entry->sha1; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 5 | my $mode = $directory_entry->mode; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 5 | my $object = $self->get_object($sha1); | |||||||||||||||||||||||||||||||||||||||||
| 438 | 5 | ▶ | if ( $object->kind eq 'blob' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | $self->_add_file( $filename, $object->content ); | |||||||||||||||||||||||||||||||||||||||||
| 440 | 5 | ▶ | chmod( oct( '0' . $mode ), $filename ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | || die "Error chmoding $filename to $mode: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 442 | } elsif ( $object->kind eq 'tree' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | dir($filename)->mkpath; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $self->checkout( $filename, $object ); | |||||||||||||||||||||||||||||||||||||||||
| 445 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | die $object->kind; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | my $remote; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | ▶ | if (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | # For backwards compatibility | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 1 | $remote = "git://$_[0]"; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | ▶ | $remote .= "/" unless $_[1] =~ m{^/}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 1 | $remote .= $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 460 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $remote = shift; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | my $protocol = Git::PurePerl::Protocol->new( | |||||||||||||||||||||||||||||||||||||||||
| 465 | remote => $remote, | ||||||||||||||||||||||||||||||||||||||||||
| 466 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | my $sha1s = $protocol->connect; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $head = $sha1s->{HEAD}; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $data = $protocol->fetch_pack($head); | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $filename | |||||||||||||||||||||||||||||||||||||||||
| 473 | = file( $self->gitdir, 'objects', 'pack', 'pack-' . $head . '.pack' ); | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $self->_add_file( $filename, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $pack | |||||||||||||||||||||||||||||||||||||||||
| 477 | = Git::PurePerl::Pack::WithoutIndex->new( filename => $filename ); | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $pack->create_index(); | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $self->update_ref( master => $head ); | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 38 | ▶ | sub _add_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_file: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 38 | my ( $class, $filename, $contents ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 38 | ▶ | my $fh = $filename->openw || confess "Error opening to $filename: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$filename->openw || confess("Error opening to ${filename}: $!")
MC/DC0%0/1
$filename->openw || confess("Error opening to ${filename}: $!")
$filename->openw
Truth table50%1/2
A
A= $filename->openw
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 38 | binmode($fh); #important for Win32 | |||||||||||||||||||||||||||||||||||||||||
| 487 | 38 | ▶ | $fh->print($contents) || confess "Error writing to $filename: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 38 | ▶ | $fh->close || confess "Error closing $filename: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | __END__ | ||||||||||||||||||||||||||||||||||||||||||