Fixings
This commit is contained in:
parent
2858ce506a
commit
771bee0aa3
|
@ -36,12 +36,17 @@ class BuildFactory
|
|||
|
||||
/**
|
||||
* Takes a generic build and returns a type-specific build model.
|
||||
* @param Build $base The build from which to get a more specific build type.
|
||||
* @param Build $build The build from which to get a more specific build type.
|
||||
* @param string $type Set the type manually if you already know it.
|
||||
* @return Build
|
||||
*/
|
||||
public static function getBuild(Build $base)
|
||||
public static function getBuild(Build $build, $type = null)
|
||||
{
|
||||
switch ($base->getProject()->getType()) {
|
||||
if (is_null($type) && !is_null($build->getProject())) {
|
||||
$type = $build->getProject()->getType();
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'remote':
|
||||
$type = 'RemoteGitBuild';
|
||||
break;
|
||||
|
@ -63,10 +68,16 @@ class BuildFactory
|
|||
case 'svn':
|
||||
$type = 'SubversionBuild';
|
||||
break;
|
||||
default:
|
||||
$type = null;
|
||||
break;
|
||||
}
|
||||
|
||||
$type = '\\PHPCI\\Model\\Build\\' . $type;
|
||||
if (!is_null($type)) {
|
||||
$type = '\\PHPCI\\Model\\Build\\' . $type;
|
||||
$build = new $type($build->getDataArray());
|
||||
}
|
||||
|
||||
return new $type($base->getDataArray());
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,12 +45,16 @@ class GithubBuild extends RemoteGitBuild
|
|||
{
|
||||
$token = \b8\Config::getInstance()->get('phpci.github.token');
|
||||
|
||||
if (empty($token)) {
|
||||
if (empty($token) || empty($this->data['id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$project = $this->getProject();
|
||||
|
||||
if (empty($project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = 'https://api.github.com/repos/'.$project->getReference().'/statuses/'.$this->getCommitId();
|
||||
$http = new \b8\HttpClient();
|
||||
|
||||
|
@ -114,10 +118,14 @@ class GithubBuild extends RemoteGitBuild
|
|||
{
|
||||
$rtn = parent::getCommitMessage($this->data['commit_message']);
|
||||
|
||||
$reference = $this->getProject()->getReference();
|
||||
$commitLink = '<a target="_blank" href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
|
||||
$rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn);
|
||||
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a target="_blank" href="https://github.com/$1">@$1</a>', $rtn);
|
||||
$project = $this->getProject();
|
||||
|
||||
if (!is_null($project)) {
|
||||
$reference = $project->getReference();
|
||||
$commitLink = '<a target="_blank" href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
|
||||
$rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn);
|
||||
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a target="_blank" href="https://github.com/$1">@$1</a>', $rtn);
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class BuildService
|
|||
|
||||
$build = $this->buildStore->save($build);
|
||||
|
||||
$build = BuildFactory::getBuild($build);
|
||||
$build = BuildFactory::getBuild($build, $project->getType());
|
||||
$build->sendStatusPostback();
|
||||
$this->addBuildToQueue($build);
|
||||
|
||||
|
@ -140,6 +140,12 @@ class BuildService
|
|||
*/
|
||||
public function addBuildToQueue(Build $build)
|
||||
{
|
||||
$buildId = $build->getId();
|
||||
|
||||
if (empty($buildId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = Config::getInstance();
|
||||
|
||||
$settings = $config->get('phpci.worker', []);
|
||||
|
|
Loading…
Reference in a new issue