PHPCI/Helper and PHPCI/Model PSR2 compliance. Issue #18
This commit is contained in:
parent
e4a6e224c4
commit
11a3e3403f
12 changed files with 1268 additions and 1294 deletions
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
namespace PHPCI\Model\Build;
|
||||
|
||||
use PHPCI\Model\Build\RemoteGitBuild;
|
||||
|
||||
/**
|
||||
|
|
@ -18,67 +19,65 @@ use PHPCI\Model\Build\RemoteGitBuild;
|
|||
*/
|
||||
class GithubBuild extends RemoteGitBuild
|
||||
{
|
||||
public function getCommitLink()
|
||||
{
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId();
|
||||
}
|
||||
public function getCommitLink()
|
||||
{
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId();
|
||||
}
|
||||
|
||||
public function getBranchLink()
|
||||
{
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch();
|
||||
}
|
||||
public function getBranchLink()
|
||||
{
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch();
|
||||
}
|
||||
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
// The postback will only work if we have an access token.
|
||||
if(!$project->getToken()) {
|
||||
return;
|
||||
}
|
||||
// The postback will only work if we have an access token.
|
||||
if (!$project->getToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId();
|
||||
$http = new \b8\HttpClient();
|
||||
$url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId();
|
||||
$http = new \b8\HttpClient();
|
||||
|
||||
switch($this->getStatus())
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
$status = 'pending';
|
||||
break;
|
||||
switch($this->getStatus())
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
$status = 'pending';
|
||||
break;
|
||||
case 2:
|
||||
$status = 'success';
|
||||
break;
|
||||
case 3:
|
||||
$status = 'failure';
|
||||
break;
|
||||
default:
|
||||
$status = 'error';
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
$status = 'success';
|
||||
break;
|
||||
$url = \b8\Registry::getInstance()->get('install_url');
|
||||
$params = array( 'state' => $status,
|
||||
'target_url' => $url . '/build/view/' . $this->getId());
|
||||
$headers = array(
|
||||
'Authorization: token ' . $project->getToken(),
|
||||
'Content-Type: application/x-www-form-urlencoded'
|
||||
);
|
||||
|
||||
case 3:
|
||||
$status = 'failure';
|
||||
break;
|
||||
$http->setHeaders($headers);
|
||||
$http->request('POST', $url, json_encode($params));
|
||||
}
|
||||
|
||||
default:
|
||||
$status = 'error';
|
||||
break;
|
||||
}
|
||||
protected function getCloneUrl()
|
||||
{
|
||||
$key = trim($this->getProject()->getGitKey());
|
||||
|
||||
$params = array( 'state' => $status,
|
||||
'target_url' => \b8\Registry::getInstance()->get('install_url') . '/build/view/' . $this->getId());
|
||||
|
||||
$http->setHeaders(array(
|
||||
'Authorization: token ' . $project->getToken(),
|
||||
'Content-Type: application/x-www-form-urlencoded'
|
||||
));
|
||||
$http->request('POST', $url, json_encode($params));
|
||||
}
|
||||
|
||||
protected function getCloneUrl()
|
||||
{
|
||||
$key = trim($this->getProject()->getGitKey());
|
||||
|
||||
if(!empty($key)) {
|
||||
return 'git@github.com:' . $this->getProject()->getReference() . '.git';
|
||||
}
|
||||
else {
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '.git';
|
||||
}
|
||||
}
|
||||
if (!empty($key)) {
|
||||
return 'git@github.com:' . $this->getProject()->getReference() . '.git';
|
||||
} else {
|
||||
return 'https://github.com/' . $this->getProject()->getReference() . '.git';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue