Github: Support pull private repository from pull request

This commit is contained in:
Martin Sadovy 2015-02-26 19:59:49 +01:00
parent b8983b23a3
commit 10a9e7b749
2 changed files with 4 additions and 2 deletions

View file

@ -236,12 +236,14 @@ class WebhookController extends \PHPCI\Controller
$committer = $commit['commit']['author']['email'];
$message = $commit['commit']['message'];
$remoteUrlKey = $payload['pull_request']['head']['repo']['private'] ? 'ssh_url' : 'clone_url';
$extra = array(
'build_type' => 'pull_request',
'pull_request_id' => $payload['pull_request']['id'],
'pull_request_number' => $payload['number'],
'remote_branch' => $payload['pull_request']['head']['ref'],
'remote_url' => $payload['pull_request']['head']['repo']['clone_url'],
'remote_url' => $payload['pull_request']['head']['repo'][$remoteUrlKey],
);
$this->createBuild($projectId, $commit['sha'], $branch, $committer, $message, $extra);

View file

@ -125,7 +125,7 @@ class GithubBuild extends RemoteGitBuild
if ($this->getExtra('build_type') == 'pull_request') {
$matches = array();
preg_match('/\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)/', $this->getExtra('remote_url'), $matches);
preg_match('/[\/:]([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)/', $this->getExtra('remote_url'), $matches);
$reference = $matches[1];
$branch = $this->getExtra('remote_branch');