Skip to content

Commit

Permalink
Support the file:// protocol, as well
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmv committed Dec 19, 2009
1 parent 914fad2 commit 7a3f586
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Git/PurePerl/Protocol.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use Moose::Util::TypeConstraints;

use Git::PurePerl::Protocol::Git;
use Git::PurePerl::Protocol::SSH;
use Git::PurePerl::Protocol::File;

has 'remote' => ( is => 'ro', isa => 'Str', required => 1 );
has 'read_socket' => ( is => 'rw', required => 0 );
Expand All @@ -19,6 +20,11 @@ sub connect {
hostname => $2,
project => $3,
);
} elsif ($self->remote =~ m{^file://(/.*)}) {
Git::PurePerl::Protocol::File->meta->rebless_instance(
$self,
path => $1,
);
} elsif ($self->remote =~ m{^ssh://(?:(.*?)@)?(.*?)(/.*)}
or $self->remote =~ m{^(?:(.*?)@)?(.*?):(.*)}) {
Git::PurePerl::Protocol::SSH->meta->rebless_instance(
Expand Down
27 changes: 27 additions & 0 deletions lib/Git/PurePerl/Protocol/File.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package Git::PurePerl::Protocol::File;
use Moose;
use MooseX::StrictConstructor;
use Moose::Util::TypeConstraints;
use IPC::Open2;

extends 'Git::PurePerl::Protocol';

has 'path' => ( is => 'ro', isa => 'Str', required => 1 );

sub connect_socket {
my $self = shift;

my ($read, $write);
my $pid = open2(
$read, $write,
"git-upload-pack",
$self->path,
);

$read->autoflush(1);
$write->autoflush(1);
$self->read_socket($read);
$self->write_socket($write);
}

1;

0 comments on commit 7a3f586

Please sign in to comment.