| 1 | package Git::PurePerl::Protocol; | ||||||||||||||||||||||||||||||||||||
| 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 Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Git::PurePerl::Protocol::Git; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Git::PurePerl::Protocol::SSH; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Git::PurePerl::Protocol::File; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||
| 11 | 4 | has 'remote' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||||||||||
| 12 | 4 | has 'read_socket' => ( is => 'rw', required => 0 ); | |||||||||||||||||||||||||||||||||||
| 13 | 4 | has 'write_socket' => ( is => 'rw', required => 0 ); | |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=7 SCAR=34.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | if ($self->remote =~ m{^git://(.*?@)?(.*?)(/.*)}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 19 | 1 | Git::PurePerl::Protocol::Git->meta->rebless_instance( | |||||||||||||||||||||||||||||||||||
| 20 | $self, | ||||||||||||||||||||||||||||||||||||
| 21 | hostname => $2, | ||||||||||||||||||||||||||||||||||||
| 22 | project => $3, | ||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||
| 24 | } elsif ($self->remote =~ m{^file://(/.*)}) { | ||||||||||||||||||||||||||||||||||||
| 25 | 0 | Git::PurePerl::Protocol::File->meta->rebless_instance( | |||||||||||||||||||||||||||||||||||
| 26 | $self, | ||||||||||||||||||||||||||||||||||||
| 27 | path => $1, | ||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||
| 29 | ▶ | } elsif ($self->remote =~ m{^ssh://(?:(.*?)@)?(.*?)(/.*)} | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->remote =~ m[^ssh://(?:(.*?)@)?(.*?)(/.*)] or $self->remote =~ /^(?:(.*?)@)?(.*?):(.*)/
MC/DC0%0/2
$self->remote =~ m[^ssh://(?:(.*?)@)?(.*?)(/.*)] or $self->remote =~ /^(?:(.*?)@)?(.*?):(.*)/
$self->remote =~ m[^ssh://(?:(.*?)@)?(.*?)(/.*)]
$self->remote =~ /^(?:(.*?)@)?(.*?):(.*)/
Truth table0%0/3
A or B
A= $self->remote =~ m[^ssh://(?:(.*?)@)?(.*?)(/.*)]B= $self->remote =~ /^(?:(.*?)@)?(.*?):(.*)/
| |||||||||||||||||||||||||||||||||||||
| 30 | or $self->remote =~ m{^(?:(.*?)@)?(.*?):(.*)}) { | ||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | Git::PurePerl::Protocol::SSH->meta->rebless_instance( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 32 | $self, | ||||||||||||||||||||||||||||||||||||
| 33 | $1 ? (username => $1) : (), | ||||||||||||||||||||||||||||||||||||
| 34 | hostname => $2, | ||||||||||||||||||||||||||||||||||||
| 35 | path => $3, | ||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||
| 39 | 1 | $self->connect_socket; | |||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 0 | my %sha1s; | |||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | while ( my $line = $self->read_line() ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||
| 44 | # warn "S $line"; | ||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ( $sha1, $name ) = $line =~ /^([a-z0-9]+) ([^\0\n]+)/; | |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||
| 47 | #use YAML; warn Dump $line; | ||||||||||||||||||||||||||||||||||||
| 48 | 0 | $sha1s{$name} = $sha1; | |||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||
| 50 | 0 | return \%sha1s; | |||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub fetch_pack { | ||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_pack: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 54 | 0 | my ( $self, $sha1 ) = @_; | |||||||||||||||||||||||||||||||||||
| 55 | 0 | $self->send_line("want $sha1 side-band-64k\n"); | |||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||
| 57 | #send_line( | ||||||||||||||||||||||||||||||||||||
| 58 | # "want 0c7b3d23c0f821e58cd20e60d5e63f5ed12ef391 multi_ack side-band-64k ofs-delta\n" | ||||||||||||||||||||||||||||||||||||
| 59 | #); | ||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->send_line(''); | |||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->send_line('done'); | |||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $pack; | |||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | while ( my $line = $self->read_line() ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $line =~ s/^\x02// ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 67 | 0 | print $line; | |||||||||||||||||||||||||||||||||||
| 68 | } elsif ( $line =~ /^NAK\n/ ) { | ||||||||||||||||||||||||||||||||||||
| 69 | } elsif ( $line =~ s/^\x01// ) { | ||||||||||||||||||||||||||||||||||||
| 70 | 0 | $pack .= $line; | |||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||
| 72 | 0 | die "Unknown line: $line"; | |||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||
| 75 | #say "s $line"; | ||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $pack; | |||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub send_line { | ||||||||||||||||||||||||||||||||||
|
Subroutine
send_line: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 81 | 0 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||
| 82 | 0 | my $length = length($line); | |||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ( $length == 0 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 84 | } else { | ||||||||||||||||||||||||||||||||||||
| 85 | 0 | $length += 4; | |||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||
| 88 | #warn "length $length"; | ||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $prefix = sprintf( "%04X", $length ); | |||||||||||||||||||||||||||||||||||
| 90 | 0 | my $text = $prefix . $line; | |||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||
| 92 | # warn "$text"; | ||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $self->write_socket->print($text) || die $!; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=4 SCAR=26.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 98 | 0 | my $len = shift; | |||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $ret = ""; | |||||||||||||||||||||||||||||||||||
| 101 | 4 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 102 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||
| 103 | 0 | my $got = $self->read_socket->read( my $data, $len - length($ret)); | |||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (not defined $got) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 105 | 0 | die "error: $!"; | |||||||||||||||||||||||||||||||||||
| 106 | } elsif ( $got == 0) { | ||||||||||||||||||||||||||||||||||||
| 107 | 0 | die "EOF" | |||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||
| 109 | 0 | $ret .= $data; | |||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (length($ret) == $len) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub read_line { | ||||||||||||||||||||||||||||||||||
|
Subroutine
read_line: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 118 | 0 | my $socket = $self->read_socket; | |||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $prefix = $self->read( 4 ); | |||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return if $prefix eq '0000'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||
| 124 | # warn "read prefix [$prefix]"; | ||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $len = 0; | |||||||||||||||||||||||||||||||||||
| 127 | 0 | foreach my $n ( 0 .. 3 ) { | |||||||||||||||||||||||||||||||||||
| 128 | 0 | my $c = substr( $prefix, $n, 1 ); | |||||||||||||||||||||||||||||||||||
| 129 | 0 | $len <<= 4; | |||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ( $c ge '0' && $c le '9' ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$c ge 0 and $c le 9
MC/DC0%0/2
$c ge 0 and $c le 9
$c ge 0
$c le 9
Truth table0%0/3
A and B
A= $c ge 0B= $c le 9
| |||||||||||||||||||||||||||||||||||||
| 132 | 0 | $len += ord($c) - ord('0'); | |||||||||||||||||||||||||||||||||||
| 133 | ▶ | } elsif ( $c ge 'a' && $c le 'f' ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$c ge "a" and $c le "f"
MC/DC0%0/2
$c ge "a" and $c le "f"
$c ge "a"
$c le "f"
Truth table0%0/3
A and B
A= $c ge "a"B= $c le "f"
| |||||||||||||||||||||||||||||||||||||
| 134 | 0 | $len += ord($c) - ord('a') + 10; | |||||||||||||||||||||||||||||||||||
| 135 | ▶ | } elsif ( $c ge 'A' && $c le 'F' ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$c ge "A" and $c le "F"
MC/DC0%0/2
$c ge "A" and $c le "F"
$c ge "A"
$c le "F"
Truth table0%0/3
A and B
A= $c ge "A"B= $c le "F"
| |||||||||||||||||||||||||||||||||||||
| 136 | 0 | $len += ord($c) - ord('A') + 10; | |||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||
| 140 | 0 | return $self->read( $len - 4 ); | |||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||
| 143 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||