/**
* @param GitLocaleCloneAction $action
*/
public function perform(GitLocaleCloneAction $action)
{
$content = $action->getData()['content'];
if (true === $action->getData()['debug']) {
$url = sprintf('https://github.com/%s/test-hook.git', $this->login);
$content['pull_request']['head']['repo']['clone_url'] = $url;
}
$cmd = [];
$cmd[] = 'cd analyze';
$cmd[] = 'mkdir -p ' . $content['pull_request']['head']['sha'];
$cmd[] = 'cd ' . $content['pull_request']['head']['sha'];
$cmd[] = sprintf('git clone -b %s %s', $content['pull_request']['head']['ref'], $content['pull_request']['head']['repo']['clone_url']);
if (null !== $this->logger) {
$this->logger->debug(sprintf('Start command %s', implode(' && ', $cmd)));
}
$process = new Process(implode(' && ', $cmd));
$process->setTimeout(360);
$process->run();
if (!$process->isSuccessful()) {
if (null !== $this->logger) {
$this->logger->error($process->getErrorOutput());
}
throw new \RuntimeException($process->getErrorOutput());
}
}