Various bug fixes

This commit is contained in:
Dan Cryer 2013-07-30 02:55:29 +01:00
parent 0adaf0c400
commit b47dfbd0b3
15 changed files with 82 additions and 43 deletions

View file

@ -10,7 +10,6 @@
namespace PHPCI;
use b8;
use b8\Registry;
use b8\Http\Response\RedirectResponse;
use b8\View;
@ -25,9 +24,6 @@ class Application extends b8\Application
*/
public function handleRequest()
{
// Registry legacy:
$registry = new b8\Registry($this->config, $this->request);
$this->initRequest();
// Validate the user's session unless it is a login/logout action or a web hook:
@ -36,9 +32,6 @@ class Application extends b8\Application
$skipValidation = ($externalAction || $sessionAction);
if($skipValidation || $this->validateSession()) {
if ( !empty($_SESSION['user']) ) {
Registry::getInstance()->set('user', $_SESSION['user']);
}
parent::handleRequest();
}

View file

@ -11,7 +11,7 @@ namespace PHPCI;
use PHPCI\Model\Build;
use b8\Store;
use Symfony\Component\Yaml\Parser as YamlParser;
use b8\Config;
/**
* PHPCI Build Runner
@ -123,7 +123,7 @@ class Builder
*/
public function getSystemConfig($key)
{
return \b8\Registry::getInstance()->get($key);
return Config::getInstance()->get($key);
}
/**
@ -319,7 +319,7 @@ class Builder
{
$commitId = $this->build->getCommitId();
$buildId = 'project' . $this->build->getProject()->getId() . '-build' . $this->build->getId();
$this->ciDir = realpath(dirname(__FILE__) . '/../') . '/';
$this->ciDir = dirname(__FILE__) . '/../';
$this->buildPath = $this->ciDir . 'build/' . $buildId . '/';
$this->setInterpolationVars();

View file

@ -10,7 +10,6 @@
namespace PHPCI\Controller;
use b8;
use b8\Registry;
use PHPCI\Model\Build;
/**

View file

@ -41,6 +41,11 @@ class GithubController extends \PHPCI\Controller
$build->setLog('');
$build->setCreated(new \DateTime());
$build->setBranch(str_replace('refs/heads/', '', $payload['ref']));
if (!empty($payload['pusher']['email'])) {
$build->setCommitterEmail($payload['pusher']['email']);
}
} catch (\Exception $ex) {
header('HTTP/1.1 400 Bad Request');
header('Ex: ' . $ex->getMessage());

View file

@ -15,7 +15,6 @@ use b8;
use b8\Controller;
use b8\Store;
use b8\Form;
use b8\Registry;
/**
* Project Controller - Allows users to create, edit and view projects.
@ -175,7 +174,7 @@ class ProjectController extends \PHPCI\Controller
*/
protected function handleGithubResponse()
{
$github = \b8\Registry::getInstance()->get('github_app');
$github = \b8\Config::getInstance()->get('phpci.github');
$code = $this->getParam('code', null);
if (!is_null($code)) {

View file

@ -10,7 +10,6 @@
namespace PHPCI\Controller;
use b8;
use b8\Registry;
use PHPCI\Model\User;
use b8\Form;

View file

@ -42,6 +42,7 @@ class BuildBase extends Model
'started' => null,
'finished' => null,
'plugins' => null,
'committer_email' => null,
);
/**
@ -58,6 +59,7 @@ class BuildBase extends Model
'started' => 'getStarted',
'finished' => 'getFinished',
'plugins' => 'getPlugins',
'committer_email' => 'getCommitterEmail',
'Project' => 'getProject',
);
@ -75,6 +77,7 @@ class BuildBase extends Model
'started' => 'setStarted',
'finished' => 'setFinished',
'plugins' => 'setPlugins',
'committer_email' => 'setCommitterEmail',
'Project' => 'setProject',
);
@ -129,6 +132,11 @@ class BuildBase extends Model
'length' => '',
'nullable' => true,
),
'committer_email' => array(
'type' => 'varchar',
'length' => '512',
'nullable' => true,
),
);
/**
@ -299,6 +307,19 @@ class BuildBase extends Model
return $rtn;
}
/**
* Get the value of CommitterEmail / committer_email.
*
* @return string
*/
public function getCommitterEmail()
{
$rtn = $this->data['committer_email'];
return $rtn;
}
/**
* Set the value of Id / id.
*
@ -309,7 +330,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] === $value) {
if ($this->data['id'] == $value) {
return;
}
@ -328,7 +349,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('ProjectId', $value);
$this->_validateInt('ProjectId', $value);
if ($this->data['project_id'] === $value) {
if ($this->data['project_id'] == $value) {
return;
}
@ -347,7 +368,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('CommitId', $value);
$this->_validateString('CommitId', $value);
if ($this->data['commit_id'] === $value) {
if ($this->data['commit_id'] == $value) {
return;
}
@ -366,7 +387,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Status', $value);
$this->_validateInt('Status', $value);
if ($this->data['status'] === $value) {
if ($this->data['status'] == $value) {
return;
}
@ -384,7 +405,7 @@ class BuildBase extends Model
{
$this->_validateString('Log', $value);
if ($this->data['log'] === $value) {
if ($this->data['log'] == $value) {
return;
}
@ -403,7 +424,7 @@ class BuildBase extends Model
{
$this->_validateNotNull('Branch', $value);
$this->_validateString('Branch', $value);
if ($this->data['branch'] === $value) {
if ($this->data['branch'] == $value) {
return;
}
@ -421,7 +442,7 @@ class BuildBase extends Model
{
$this->_validateDate('Created', $value);
if ($this->data['created'] === $value) {
if ($this->data['created'] == $value) {
return;
}
@ -439,7 +460,7 @@ class BuildBase extends Model
{
$this->_validateDate('Started', $value);
if ($this->data['started'] === $value) {
if ($this->data['started'] == $value) {
return;
}
@ -457,7 +478,7 @@ class BuildBase extends Model
{
$this->_validateDate('Finished', $value);
if ($this->data['finished'] === $value) {
if ($this->data['finished'] == $value) {
return;
}
@ -475,7 +496,7 @@ class BuildBase extends Model
{
$this->_validateString('Plugins', $value);
if ($this->data['plugins'] === $value) {
if ($this->data['plugins'] == $value) {
return;
}
@ -484,6 +505,24 @@ class BuildBase extends Model
$this->_setModified('plugins');
}
/**
* Set the value of CommitterEmail / committer_email.
*
* @param $value string
*/
public function setCommitterEmail($value)
{
$this->_validateString('CommitterEmail', $value);
if ($this->data['committer_email'] == $value) {
return;
}
$this->data['committer_email'] = $value;
$this->_setModified('committer_email');
}
/**
* Get the Project model for this Build by Id.
*

View file

@ -199,7 +199,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] === $value) {
if ($this->data['id'] == $value) {
return;
}
@ -218,7 +218,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Title', $value);
$this->_validateString('Title', $value);
if ($this->data['title'] === $value) {
if ($this->data['title'] == $value) {
return;
}
@ -237,7 +237,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Reference', $value);
$this->_validateString('Reference', $value);
if ($this->data['reference'] === $value) {
if ($this->data['reference'] == $value) {
return;
}
@ -256,7 +256,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('GitKey', $value);
$this->_validateString('GitKey', $value);
if ($this->data['git_key'] === $value) {
if ($this->data['git_key'] == $value) {
return;
}
@ -275,7 +275,7 @@ class ProjectBase extends Model
{
$this->_validateNotNull('Type', $value);
$this->_validateString('Type', $value);
if ($this->data['type'] === $value) {
if ($this->data['type'] == $value) {
return;
}
@ -293,7 +293,7 @@ class ProjectBase extends Model
{
$this->_validateString('Token', $value);
if ($this->data['token'] === $value) {
if ($this->data['token'] == $value) {
return;
}

View file

@ -179,7 +179,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Id', $value);
$this->_validateInt('Id', $value);
if ($this->data['id'] === $value) {
if ($this->data['id'] == $value) {
return;
}
@ -198,7 +198,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Email', $value);
$this->_validateString('Email', $value);
if ($this->data['email'] === $value) {
if ($this->data['email'] == $value) {
return;
}
@ -217,7 +217,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Hash', $value);
$this->_validateString('Hash', $value);
if ($this->data['hash'] === $value) {
if ($this->data['hash'] == $value) {
return;
}
@ -236,7 +236,7 @@ class UserBase extends Model
{
$this->_validateNotNull('IsAdmin', $value);
$this->_validateInt('IsAdmin', $value);
if ($this->data['is_admin'] === $value) {
if ($this->data['is_admin'] == $value) {
return;
}
@ -255,7 +255,7 @@ class UserBase extends Model
{
$this->_validateNotNull('Name', $value);
$this->_validateString('Name', $value);
if ($this->data['name'] === $value) {
if ($this->data['name'] == $value) {
return;
}

View file

@ -67,7 +67,7 @@ class GithubBuild extends RemoteGitBuild
break;
}
$url = \b8\Registry::getInstance()->get('install_url');
$url = \b8\Config::getInstance()->get('phpci.url');
$params = array( 'state' => $status,
'target_url' => $url . '/build/view/' . $this->getId());
$headers = array(

View file

@ -74,7 +74,14 @@ class RemoteGitBuild extends Build
protected function cloneBySsh(Builder $builder, $to)
{
// Copy the project's keyfile to disk:
$keyFile = realpath($to) . '.key';
$keyPath = realpath($to);
if ($keyPath === false) {
$keyPath = dirname($to);
}
$keyFile = $keyPath . '.key';
file_put_contents($keyFile, $this->getProject()->getGitKey());
chmod($keyFile, 0600);

View file

@ -25,7 +25,7 @@
window.return_url = <?php print json_encode((empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); ?>;
<?php
$gh = \b8\Registry::getInstance()->get('github_app', null);
$gh = \b8\Config::getInstance()->get('phpci.github', null);
if($gh) {
print 'window.github_app_id = ' . json_encode($gh['id']) . ';' . PHP_EOL;

View file

@ -80,8 +80,8 @@ foreach($projects as $projectId => $project):
break;
}
$health = ($project['health'] < 0 ? 'Stormy': ($project['health'] < 5? 'Overcast': 'Sunny'));
$subcls = ($project['health'] < 0 ? 'important': ($project['health'] < 5? 'warning': 'success'));
$health = ($project['health'] <= 0 ? 'Stormy': ($project['successes'] < $project['count']? 'Overcast': 'Sunny'));
$subcls = ($project['health'] <= 0 ? 'important': ($project['successes'] < $project['count']? 'warning': 'success'));
?>
<tr class="<?php print $cls; ?>">
<td>

View file

@ -42,8 +42,6 @@ $conf['b8']['app']['default_controller'] = 'Index';
$conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/';
$config = new b8\Config($conf);
$request = new b8\Http\Request();
$registry = new b8\Registry($config, $request);
if (file_exists(APPLICATION_PATH . 'config.php')) {
require(APPLICATION_PATH . 'config.php');

View file

@ -14,5 +14,5 @@ ini_set('display_errors', 'on');
require_once('bootstrap.php');
$fc = new PHPCI\Application($config, $request);
$fc = new PHPCI\Application($config, new b8\Http\Request());
print $fc->handleRequest();