From 60131ae7b6a9cdf0c7660ce6cfc98ffd69af98ad Mon Sep 17 00:00:00 2001 From: Martin Sadovy Date: Thu, 26 Feb 2015 19:59:49 +0100 Subject: [PATCH] Github: Support pull private repository from pull request Closes #832 --- PHPCI/Controller/WebhookController.php | 4 +++- PHPCI/Model/Build/GithubBuild.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PHPCI/Controller/WebhookController.php b/PHPCI/Controller/WebhookController.php index e05cfbda..45a775ad 100644 --- a/PHPCI/Controller/WebhookController.php +++ b/PHPCI/Controller/WebhookController.php @@ -260,12 +260,14 @@ class WebhookController extends \b8\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], ); $results[$id] = $this->createBuild($project, $id, $branch, $committer, $message, $extra); diff --git a/PHPCI/Model/Build/GithubBuild.php b/PHPCI/Model/Build/GithubBuild.php index 4d61b9d6..d6b2b7b9 100644 --- a/PHPCI/Model/Build/GithubBuild.php +++ b/PHPCI/Model/Build/GithubBuild.php @@ -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');