Skip to content

Commit

Permalink
fix issue #6394: capture git stderr/stdout
Browse files Browse the repository at this point in the history
Adds new dependency: perl(IPC::Run::Debug)
  • Loading branch information
asdil12 committed Jul 29, 2015
1 parent c7accde commit 9a9e785
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions DEPENDENCIES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FindBin
Getopt::Long
IO::Socket::INET6
IO::Socket::SSL
IPC::Run::Debug
JSON
LWP::UserAgent
List::MoreUtils
Expand Down
21 changes: 18 additions & 3 deletions lib/OpenQA/WebAPI/Controller/Step.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use File::Which qw(which);
use POSIX qw/strftime/;
use Try::Tiny;
use JSON;
use IPC::Run();

sub init {
my $self = shift;
Expand Down Expand Up @@ -353,16 +354,30 @@ sub _commit_git {
}
my @git = ('git', '--git-dir', "$dir/.git", '--work-tree', $dir);
my @files = ($dir . '/' . $name . '.json', $dir . '/' . $name . '.png');
if (system(@git, 'add', @files) != 0) {

my ($stdin, $stdout_err, $ret);

$ret = IPC::Run::run([@git, 'add', @files], \$stdin, '>&', \$stdout_err);
chomp $stdout_err;
$self->app->log->debug($stdout_err);
unless ($ret) {
die "failed to git add $name";
}

my @cmd = (@git, 'commit', '-q', '-m', sprintf("%s for %s", $name, $job->name), sprintf('--author=%s <%s>', $self->current_user->fullname, $self->current_user->email), @files);
$self->app->log->debug(join(' ', @cmd));
if (system(@cmd) != 0) {
$ret = IPC::Run::run([@cmd], \$stdin, '>&', \$stdout_err);
chomp $stdout_err;
$self->app->log->debug($stdout_err);
unless ($ret) {
die "failed to git commit $name";
}

if (($self->app->config->{'scm git'}->{'do_push'} || '') eq 'yes') {
if (system(@git, 'push') != 0) {
$ret = IPC::Run::run([@git, 'push'], \$stdin, '>&', \$stdout_err);
chomp $stdout_err;
$self->app->log->debug($stdout_err);
unless ($ret) {
die "failed to git push $name";
}
}
Expand Down

0 comments on commit 9a9e785

Please sign in to comment.