File: SSH.pm

package info (click to toggle)
libgit-pureperl-perl 0.53-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 368 kB
  • sloc: perl: 3,153; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package Git::PurePerl::Protocol::SSH;
use Moose;
use MooseX::StrictConstructor;
use Moose::Util::TypeConstraints;
use IPC::Open2;
use namespace::autoclean;

extends 'Git::PurePerl::Protocol';

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

sub connect_socket {
    my $self = shift;

    my ($read, $write);
    my $connect = join('@', grep {defined} $self->username, $self->hostname);
    my $pid = open2(
        $read, $write,
        "ssh", $connect,
        "-o", "BatchMode yes",
        "git-upload-pack", $self->path,
    );

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

1;