Skip to content

Commit 7a3f586

Browse files
committed
Support the file:// protocol, as well
1 parent 914fad2 commit 7a3f586

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/Git/PurePerl/Protocol.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Moose::Util::TypeConstraints;
55

66
use Git::PurePerl::Protocol::Git;
77
use Git::PurePerl::Protocol::SSH;
8+
use Git::PurePerl::Protocol::File;
89

910
has 'remote' => ( is => 'ro', isa => 'Str', required => 1 );
1011
has 'read_socket' => ( is => 'rw', required => 0 );
@@ -19,6 +20,11 @@ sub connect {
1920
hostname => $2,
2021
project => $3,
2122
);
23+
} elsif ($self->remote =~ m{^file://(/.*)}) {
24+
Git::PurePerl::Protocol::File->meta->rebless_instance(
25+
$self,
26+
path => $1,
27+
);
2228
} elsif ($self->remote =~ m{^ssh://(?:(.*?)@)?(.*?)(/.*)}
2329
or $self->remote =~ m{^(?:(.*?)@)?(.*?):(.*)}) {
2430
Git::PurePerl::Protocol::SSH->meta->rebless_instance(

lib/Git/PurePerl/Protocol/File.pm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package Git::PurePerl::Protocol::File;
2+
use Moose;
3+
use MooseX::StrictConstructor;
4+
use Moose::Util::TypeConstraints;
5+
use IPC::Open2;
6+
7+
extends 'Git::PurePerl::Protocol';
8+
9+
has 'path' => ( is => 'ro', isa => 'Str', required => 1 );
10+
11+
sub connect_socket {
12+
my $self = shift;
13+
14+
my ($read, $write);
15+
my $pid = open2(
16+
$read, $write,
17+
"git-upload-pack",
18+
$self->path,
19+
);
20+
21+
$read->autoflush(1);
22+
$write->autoflush(1);
23+
$self->read_socket($read);
24+
$self->write_socket($write);
25+
}
26+
27+
1;

0 commit comments

Comments
 (0)