Skip to content

Commit

Permalink
extended debug for git interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
bambr committed Jun 28, 2023
1 parent 10d14b3 commit 03a9254
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 10 additions & 4 deletions lib/App/cpm/Worker/Installer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,22 @@ sub _fetch_git {
DIR => $self->menlo->{base},
);
$self->menlo->mask_output( diag_progress => "Cloning $uri" );
$self->menlo->run_command([ 'git', 'clone', $uri, $dir ]);

unless (-e "$dir/.git") {
my ($ok, $res) = $self->menlo->run_command([ 'git', 'clone', $uri, $dir ]);
if (!$ok || !-e "$dir/.git") {
$self->menlo->diag_fail("Failed cloning git repository $uri", 1);
if ($res->{stdout}) {
$self->menlo->diag_fail($_, 1) foreach map { " $_" } split /\r?\n/, $res->{stdout};
}
return;
}
my $guard = pushd $dir;
if ($ref) {
unless ($self->menlo->run_command([ 'git', 'checkout', $ref ])) {
($ok, $res) = $self->menlo->run_command([ 'git', 'checkout', $ref ]);
unless ($ok) {
$self->menlo->diag_fail("Failed to checkout '$ref' in git repository $uri\n");
if ($res->{stdout}) {
$self->menlo->diag_fail($_, 1) foreach map { " $_" } split /\r?\n/, $res->{stdout};
}
return;
}
}
Expand Down
7 changes: 3 additions & 4 deletions lib/App/cpm/Worker/Installer/Menlo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ sub log {
sub run_command {
my ($self, $cmd) = @_;
$self->run_timeout($cmd, 0);

}

sub run_timeout {
Expand All @@ -66,7 +65,7 @@ sub run_timeout {

my $runner = Command::Runner->new(
command => $cmd,
keep => 0,
keep => 1,
redirect => 1,
timeout => $timeout,
stdout => sub { $self->log(@_) },
Expand All @@ -76,8 +75,8 @@ sub run_timeout {
$self->diag_fail("Timed out (> ${timeout}s).");
return;
}
my $result = $res->{result};
ref $cmd eq 'CODE' ? $result : $result == 0;
my $result = ref $cmd eq 'CODE' ? $res->{result} : $res->{result} == 0;
return wantarray ? ($result, $res) : $result;
}

1;

0 comments on commit 03a9254

Please sign in to comment.