Code style fixes.
This commit is contained in:
parent
a16c82babc
commit
50b117455e
|
@ -55,7 +55,7 @@ class RebuildQueueCommand extends Command
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$store = Factory::getStore('Build');
|
$store = Factory::getStore('Build');
|
||||||
$result = $store->getByStatus(0);
|
$result = $store->getByStatus(0);
|
||||||
|
|
||||||
$this->logger->addInfo(sprintf('Found %d builds', count($result['items'])));
|
$this->logger->addInfo(sprintf('Found %d builds', count($result['items'])));
|
||||||
|
|
|
@ -119,10 +119,10 @@ class BuildController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rebuild = Lang::get('rebuild_now');
|
$rebuild = Lang::get('rebuild_now');
|
||||||
$rebuildLink = APP_URL . 'build/rebuild/' . $build->getId();
|
$rebuildLink = APP_URL . 'build/rebuild/' . $build->getId();
|
||||||
|
|
||||||
$delete = Lang::get('delete_build');
|
$delete = Lang::get('delete_build');
|
||||||
$deleteLink = APP_URL . 'build/delete/' . $build->getId();
|
$deleteLink = APP_URL . 'build/delete/' . $build->getId();
|
||||||
|
|
||||||
$project = Factory::getStore('Project')->getByPrimaryKey($build->getProjectId());
|
$project = Factory::getStore('Project')->getByPrimaryKey($build->getProjectId());
|
||||||
|
|
|
@ -82,7 +82,7 @@ class BuildStatusController extends Controller
|
||||||
{
|
{
|
||||||
/* @var Project $project */
|
/* @var Project $project */
|
||||||
$project = $this->projectStore->getById($projectId);
|
$project = $this->projectStore->getById($projectId);
|
||||||
$xml = new \SimpleXMLElement('<Projects/>');
|
$xml = new \SimpleXMLElement('<Projects/>');
|
||||||
|
|
||||||
if (!$project instanceof Project || !$project->getAllowPublicStatus()) {
|
if (!$project instanceof Project || !$project->getAllowPublicStatus()) {
|
||||||
return $this->renderXml($xml);
|
return $this->renderXml($xml);
|
||||||
|
|
|
@ -19,10 +19,11 @@ class HomeController extends Controller
|
||||||
$this->layout->title = Lang::get('dashboard');
|
$this->layout->title = Lang::get('dashboard');
|
||||||
|
|
||||||
$widgets = [
|
$widgets = [
|
||||||
'left' => [],
|
'left' => [],
|
||||||
'right' => [],
|
'right' => [],
|
||||||
];
|
];
|
||||||
$widgets_config = Config::getInstance()->get('php-censor.dashboard_widgets', [
|
|
||||||
|
$widgetsConfig = Config::getInstance()->get('php-censor.dashboard_widgets', [
|
||||||
'all_projects' => [
|
'all_projects' => [
|
||||||
'side' => 'left',
|
'side' => 'left',
|
||||||
],
|
],
|
||||||
|
@ -30,7 +31,8 @@ class HomeController extends Controller
|
||||||
'side' => 'right',
|
'side' => 'right',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
foreach($widgets_config as $name => $params) {
|
|
||||||
|
foreach($widgetsConfig as $name => $params) {
|
||||||
$side = (isset($params['side']) && 'right' === $params['side'])
|
$side = (isset($params['side']) && 'right' === $params['side'])
|
||||||
? 'right'
|
? 'right'
|
||||||
: 'left';
|
: 'left';
|
||||||
|
|
|
@ -189,17 +189,15 @@ class SessionController extends Controller
|
||||||
{
|
{
|
||||||
if ($this->request->getMethod() == 'POST') {
|
if ($this->request->getMethod() == 'POST') {
|
||||||
$email = $this->getParam('email', null);
|
$email = $this->getParam('email', null);
|
||||||
$user = $this->userStore->getByEmail($email);
|
$user = $this->userStore->getByEmail($email);
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
$this->view->error = Lang::get('reset_no_user_exists');
|
$this->view->error = Lang::get('reset_no_user_exists');
|
||||||
return $this->view->render();
|
return $this->view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = md5(date('Y-m-d') . $user->getHash());
|
$key = md5(date('Y-m-d') . $user->getHash());
|
||||||
$url = APP_URL;
|
$message = Lang::get('reset_email_body', $user->getName(), APP_URL, $user->getId(), $key);
|
||||||
|
|
||||||
$message = Lang::get('reset_email_body', $user->getName(), $url, $user->getId(), $key);
|
|
||||||
|
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
$email->setEmailTo($user->getEmail(), $user->getName());
|
$email->setEmailTo($user->getEmail(), $user->getName());
|
||||||
|
|
|
@ -197,7 +197,7 @@ class UserController extends Controller
|
||||||
$this->requireAdmin();
|
$this->requireAdmin();
|
||||||
|
|
||||||
$method = $this->request->getMethod();
|
$method = $this->request->getMethod();
|
||||||
$user = $this->userStore->getById($userId);
|
$user = $this->userStore->getById($userId);
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
||||||
|
@ -291,7 +291,7 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
$this->requireAdmin();
|
$this->requireAdmin();
|
||||||
|
|
||||||
$user = $this->userStore->getById($userId);
|
$user = $this->userStore->getById($userId);
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
||||||
|
|
|
@ -423,10 +423,10 @@ class WebhookController extends Controller
|
||||||
$url = $payload['pull_request']['commits_url'];
|
$url = $payload['pull_request']['commits_url'];
|
||||||
|
|
||||||
//for large pull requests, allow grabbing more then the default number of commits
|
//for large pull requests, allow grabbing more then the default number of commits
|
||||||
$custom_per_page = Config::getInstance()->get('php-censor.github.per_page');
|
$customPerPage = Config::getInstance()->get('php-censor.github.per_page');
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($custom_per_page) {
|
if ($customPerPage) {
|
||||||
$params['per_page'] = $custom_per_page;
|
$params['per_page'] = $customPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
@ -490,12 +490,12 @@ class WebhookController extends Controller
|
||||||
$project = $this->fetchProject($projectId, ['gitlab', 'git']);
|
$project = $this->fetchProject($projectId, ['gitlab', 'git']);
|
||||||
|
|
||||||
$payloadString = file_get_contents("php://input");
|
$payloadString = file_get_contents("php://input");
|
||||||
$payload = json_decode($payloadString, true);
|
$payload = json_decode($payloadString, true);
|
||||||
|
|
||||||
// build on merge request events
|
// build on merge request events
|
||||||
if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') {
|
if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') {
|
||||||
$attributes = $payload['object_attributes'];
|
$attributes = $payload['object_attributes'];
|
||||||
if ($attributes['state'] == 'opened' || $attributes['state'] == 'reopened') {
|
if ($attributes['state'] === 'opened' || $attributes['state'] === 'reopened') {
|
||||||
$branch = $attributes['source_branch'];
|
$branch = $attributes['source_branch'];
|
||||||
$commit = $attributes['last_commit'];
|
$commit = $attributes['last_commit'];
|
||||||
$committer = $commit['author']['email'];
|
$committer = $commit['author']['email'];
|
||||||
|
@ -520,8 +520,8 @@ class WebhookController extends Controller
|
||||||
$status = 'failed';
|
$status = 'failed';
|
||||||
foreach ($payload['commits'] as $commit) {
|
foreach ($payload['commits'] as $commit) {
|
||||||
try {
|
try {
|
||||||
$branch = str_replace('refs/heads/', '', $payload['ref']);
|
$branch = str_replace('refs/heads/', '', $payload['ref']);
|
||||||
$committer = $commit['author']['email'];
|
$committer = $commit['author']['email'];
|
||||||
$results[$commit['id']] = $this->createBuild(
|
$results[$commit['id']] = $this->createBuild(
|
||||||
Build::SOURCE_WEBHOOK,
|
Build::SOURCE_WEBHOOK,
|
||||||
$project,
|
$project,
|
||||||
|
@ -554,11 +554,11 @@ class WebhookController extends Controller
|
||||||
*/
|
*/
|
||||||
public function svn($projectId)
|
public function svn($projectId)
|
||||||
{
|
{
|
||||||
$project = $this->fetchProject($projectId, 'svn');
|
$project = $this->fetchProject($projectId, 'svn');
|
||||||
$branch = $this->getParam('branch', $project->getBranch());
|
$branch = $this->getParam('branch', $project->getBranch());
|
||||||
$commit = $this->getParam('commit');
|
$commit = $this->getParam('commit');
|
||||||
$commitMessage = $this->getParam('message');
|
$commitMessage = $this->getParam('message');
|
||||||
$committer = $this->getParam('committer');
|
$committer = $this->getParam('committer');
|
||||||
|
|
||||||
return $this->createBuild(
|
return $this->createBuild(
|
||||||
Build::SOURCE_WEBHOOK,
|
Build::SOURCE_WEBHOOK,
|
||||||
|
@ -770,13 +770,13 @@ class WebhookController extends Controller
|
||||||
// Check if a build already exists for this commit ID:
|
// Check if a build already exists for this commit ID:
|
||||||
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
|
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
|
||||||
|
|
||||||
$ignore_environments = [];
|
$ignoreEnvironments = [];
|
||||||
$ignore_tags = [];
|
$ignoreTags = [];
|
||||||
if ($builds['count']) {
|
if ($builds['count']) {
|
||||||
foreach($builds['items'] as $build) {
|
foreach($builds['items'] as $build) {
|
||||||
/** @var Build $build */
|
/** @var Build $build */
|
||||||
$ignore_environments[$build->getId()] = $build->getEnvironment();
|
$ignoreEnvironments[$build->getId()] = $build->getEnvironment();
|
||||||
$ignore_tags[$build->getId()] = $build->getTag();
|
$ignoreTags[$build->getId()] = $build->getTag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,20 +790,20 @@ class WebhookController extends Controller
|
||||||
|
|
||||||
$environments = $project->getEnvironmentsObjects();
|
$environments = $project->getEnvironmentsObjects();
|
||||||
if ($environments['count']) {
|
if ($environments['count']) {
|
||||||
$created_builds = [];
|
$createdBuilds = [];
|
||||||
$environment_names = $project->getEnvironmentsNamesByBranch($branch);
|
$environmentNames = $project->getEnvironmentsNamesByBranch($branch);
|
||||||
// use base branch from project
|
// use base branch from project
|
||||||
if (!empty($environment_names)) {
|
if (!empty($environmentNames)) {
|
||||||
$duplicates = [];
|
$duplicates = [];
|
||||||
foreach ($environment_names as $environment_name) {
|
foreach ($environmentNames as $environmentName) {
|
||||||
if (
|
if (
|
||||||
!in_array($environment_name, $ignore_environments) ||
|
!in_array($environmentName, $ignoreEnvironments) ||
|
||||||
($tag && !in_array($tag, $ignore_tags, true))
|
($tag && !in_array($tag, $ignoreTags, true))
|
||||||
) {
|
) {
|
||||||
// If not, create a new build job for it:
|
// If not, create a new build job for it:
|
||||||
$build = $this->buildService->createBuild(
|
$build = $this->buildService->createBuild(
|
||||||
$project,
|
$project,
|
||||||
$environment_name,
|
$environmentName,
|
||||||
$commitId,
|
$commitId,
|
||||||
$project->getBranch(),
|
$project->getBranch(),
|
||||||
$tag,
|
$tag,
|
||||||
|
@ -814,19 +814,19 @@ class WebhookController extends Controller
|
||||||
$extra
|
$extra
|
||||||
);
|
);
|
||||||
|
|
||||||
$created_builds[] = [
|
$createdBuilds[] = [
|
||||||
'id' => $build->getID(),
|
'id' => $build->getID(),
|
||||||
'environment' => $environment_name,
|
'environment' => $environmentName,
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$duplicates[] = array_search($environment_name, $ignore_environments);
|
$duplicates[] = array_search($environmentName, $ignoreEnvironments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($created_builds)) {
|
if (!empty($createdBuilds)) {
|
||||||
if (empty($duplicates)) {
|
if (empty($duplicates)) {
|
||||||
return ['status' => 'ok', 'builds' => $created_builds];
|
return ['status' => 'ok', 'builds' => $createdBuilds];
|
||||||
} else {
|
} else {
|
||||||
return ['status' => 'ok', 'builds' => $created_builds, 'message' => sprintf('For this commit some builds already exists (%s)', implode(', ', $duplicates))];
|
return ['status' => 'ok', 'builds' => $createdBuilds, 'message' => sprintf('For this commit some builds already exists (%s)', implode(', ', $duplicates))];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ['status' => 'ignored', 'message' => sprintf('For this commit already created builds (%s)', implode(', ', $duplicates))];
|
return ['status' => 'ignored', 'message' => sprintf('For this commit already created builds (%s)', implode(', ', $duplicates))];
|
||||||
|
@ -835,10 +835,10 @@ class WebhookController extends Controller
|
||||||
return ['status' => 'ignored', 'message' => 'Branch not assigned to any environment'];
|
return ['status' => 'ignored', 'message' => 'Branch not assigned to any environment'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$environment_name = null;
|
$environmentName = null;
|
||||||
if (
|
if (
|
||||||
!in_array($environment_name, $ignore_environments, true) ||
|
!in_array($environmentName, $ignoreEnvironments, true) ||
|
||||||
($tag && !in_array($tag, $ignore_tags, true))
|
($tag && !in_array($tag, $ignoreTags, true))
|
||||||
) {
|
) {
|
||||||
$build = $this->buildService->createBuild(
|
$build = $this->buildService->createBuild(
|
||||||
$project,
|
$project,
|
||||||
|
@ -857,7 +857,7 @@ class WebhookController extends Controller
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'status' => 'ignored',
|
'status' => 'ignored',
|
||||||
'message' => sprintf('Duplicate of build #%d', array_search($environment_name, $ignore_environments)),
|
'message' => sprintf('Duplicate of build #%d', array_search($environmentName, $ignoreEnvironments)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,15 +72,15 @@ class WidgetBuildErrorsController extends Controller
|
||||||
$view->builds = $builds['projects'];
|
$view->builds = $builds['projects'];
|
||||||
$projects = $this->projectStore->getByIds(array_keys($builds['projects']));
|
$projects = $this->projectStore->getByIds(array_keys($builds['projects']));
|
||||||
|
|
||||||
$view_projects = [];
|
$viewProjects = [];
|
||||||
foreach($projects as $id => $project) {
|
foreach($projects as $id => $project) {
|
||||||
if (!$project->getArchived()) {
|
if (!$project->getArchived()) {
|
||||||
$view_projects[$id] = $project;
|
$viewProjects[$id] = $project;
|
||||||
} else {
|
} else {
|
||||||
unset($builds['projects'][$id]);
|
unset($builds['projects'][$id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$view->projects = $view_projects;
|
$view->projects = $viewProjects;
|
||||||
} else {
|
} else {
|
||||||
$view = new View('WidgetBuildErrors/empty');
|
$view = new View('WidgetBuildErrors/empty');
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Bitbucket
|
||||||
*/
|
*/
|
||||||
public function getPullRequestDiff($repo, $pullRequestId)
|
public function getPullRequestDiff($repo, $pullRequestId)
|
||||||
{
|
{
|
||||||
$username = Config::getInstance()->get('php-censor.bitbucket.username');
|
$username = Config::getInstance()->get('php-censor.bitbucket.username');
|
||||||
$appPassword = Config::getInstance()->get('php-censor.bitbucket.app_password');
|
$appPassword = Config::getInstance()->get('php-censor.bitbucket.app_password');
|
||||||
|
|
||||||
if (empty($username) || empty($appPassword)) {
|
if (empty($username) || empty($appPassword)) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use PHPCensor\Model\Build as BaseBuild;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The BuildInterpolator class replaces variables in a string with build-specific information.
|
* The BuildInterpolator class replaces variables in a string with build-specific information.
|
||||||
*
|
*
|
||||||
* @package PHPCensor\Helper
|
* @package PHPCensor\Helper
|
||||||
*/
|
*/
|
||||||
class BuildInterpolator
|
class BuildInterpolator
|
||||||
|
@ -17,7 +17,7 @@ class BuildInterpolator
|
||||||
* @var mixed[]
|
* @var mixed[]
|
||||||
* @see setupInterpolationVars()
|
* @see setupInterpolationVars()
|
||||||
*/
|
*/
|
||||||
protected $interpolation_vars = [];
|
protected $interpolationVars = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the variables that will be used for interpolation.
|
* Sets the variables that will be used for interpolation.
|
||||||
|
@ -28,46 +28,46 @@ class BuildInterpolator
|
||||||
*/
|
*/
|
||||||
public function setupInterpolationVars(BaseBuild $build, $buildPath, $url)
|
public function setupInterpolationVars(BaseBuild $build, $buildPath, $url)
|
||||||
{
|
{
|
||||||
$this->interpolation_vars = [];
|
$this->interpolationVars = [];
|
||||||
$this->interpolation_vars['%PHPCI%'] = 1;
|
$this->interpolationVars['%PHPCI%'] = 1;
|
||||||
$this->interpolation_vars['%COMMIT%'] = $build->getCommitId();
|
$this->interpolationVars['%COMMIT%'] = $build->getCommitId();
|
||||||
$this->interpolation_vars['%SHORT_COMMIT%'] = substr($build->getCommitId(), 0, 7);
|
$this->interpolationVars['%SHORT_COMMIT%'] = substr($build->getCommitId(), 0, 7);
|
||||||
$this->interpolation_vars['%COMMIT_EMAIL%'] = $build->getCommitterEmail();
|
$this->interpolationVars['%COMMIT_EMAIL%'] = $build->getCommitterEmail();
|
||||||
$this->interpolation_vars['%COMMIT_MESSAGE%'] = $build->getCommitMessage();
|
$this->interpolationVars['%COMMIT_MESSAGE%'] = $build->getCommitMessage();
|
||||||
$this->interpolation_vars['%COMMIT_URI%'] = $build->getCommitLink();
|
$this->interpolationVars['%COMMIT_URI%'] = $build->getCommitLink();
|
||||||
$this->interpolation_vars['%BRANCH%'] = $build->getBranch();
|
$this->interpolationVars['%BRANCH%'] = $build->getBranch();
|
||||||
$this->interpolation_vars['%BRANCH_URI%'] = $build->getBranchLink();
|
$this->interpolationVars['%BRANCH_URI%'] = $build->getBranchLink();
|
||||||
$this->interpolation_vars['%ENVIRONMENT%'] = $build->getEnvironment();
|
$this->interpolationVars['%ENVIRONMENT%'] = $build->getEnvironment();
|
||||||
$this->interpolation_vars['%PROJECT%'] = $build->getProjectId();
|
$this->interpolationVars['%PROJECT%'] = $build->getProjectId();
|
||||||
$this->interpolation_vars['%BUILD%'] = $build->getId();
|
$this->interpolationVars['%BUILD%'] = $build->getId();
|
||||||
$this->interpolation_vars['%PROJECT_TITLE%'] = $build->getProjectTitle();
|
$this->interpolationVars['%PROJECT_TITLE%'] = $build->getProjectTitle();
|
||||||
$this->interpolation_vars['%PROJECT_URI%'] = $url . "project/view/" . $build->getProjectId();
|
$this->interpolationVars['%PROJECT_URI%'] = $url . "project/view/" . $build->getProjectId();
|
||||||
$this->interpolation_vars['%BUILD_PATH%'] = $buildPath;
|
$this->interpolationVars['%BUILD_PATH%'] = $buildPath;
|
||||||
$this->interpolation_vars['%BUILD_URI%'] = $url . "build/view/" . $build->getId();
|
$this->interpolationVars['%BUILD_URI%'] = $url . "build/view/" . $build->getId();
|
||||||
$this->interpolation_vars['%PHPCI_COMMIT%'] = $this->interpolation_vars['%COMMIT%'];
|
$this->interpolationVars['%PHPCI_COMMIT%'] = $this->interpolationVars['%COMMIT%'];
|
||||||
$this->interpolation_vars['%PHPCI_SHORT_COMMIT%'] = $this->interpolation_vars['%SHORT_COMMIT%'];
|
$this->interpolationVars['%PHPCI_SHORT_COMMIT%'] = $this->interpolationVars['%SHORT_COMMIT%'];
|
||||||
$this->interpolation_vars['%PHPCI_COMMIT_MESSAGE%'] = $this->interpolation_vars['%COMMIT_MESSAGE%'];
|
$this->interpolationVars['%PHPCI_COMMIT_MESSAGE%'] = $this->interpolationVars['%COMMIT_MESSAGE%'];
|
||||||
$this->interpolation_vars['%PHPCI_COMMIT_EMAIL%'] = $this->interpolation_vars['%COMMIT_EMAIL%'];
|
$this->interpolationVars['%PHPCI_COMMIT_EMAIL%'] = $this->interpolationVars['%COMMIT_EMAIL%'];
|
||||||
$this->interpolation_vars['%PHPCI_COMMIT_URI%'] = $this->interpolation_vars['%COMMIT_URI%'];
|
$this->interpolationVars['%PHPCI_COMMIT_URI%'] = $this->interpolationVars['%COMMIT_URI%'];
|
||||||
$this->interpolation_vars['%PHPCI_PROJECT%'] = $this->interpolation_vars['%PROJECT%'];
|
$this->interpolationVars['%PHPCI_PROJECT%'] = $this->interpolationVars['%PROJECT%'];
|
||||||
$this->interpolation_vars['%PHPCI_BUILD%'] = $this->interpolation_vars['%BUILD%'];
|
$this->interpolationVars['%PHPCI_BUILD%'] = $this->interpolationVars['%BUILD%'];
|
||||||
$this->interpolation_vars['%PHPCI_PROJECT_TITLE%'] = $this->interpolation_vars['%PROJECT_TITLE%'];
|
$this->interpolationVars['%PHPCI_PROJECT_TITLE%'] = $this->interpolationVars['%PROJECT_TITLE%'];
|
||||||
$this->interpolation_vars['%PHPCI_PROJECT_URI%'] = $this->interpolation_vars['%PROJECT_URI%'];
|
$this->interpolationVars['%PHPCI_PROJECT_URI%'] = $this->interpolationVars['%PROJECT_URI%'];
|
||||||
$this->interpolation_vars['%PHPCI_BUILD_PATH%'] = $this->interpolation_vars['%BUILD_PATH%'];
|
$this->interpolationVars['%PHPCI_BUILD_PATH%'] = $this->interpolationVars['%BUILD_PATH%'];
|
||||||
$this->interpolation_vars['%PHPCI_BUILD_URI%'] = $this->interpolation_vars['%BUILD_URI%'];
|
$this->interpolationVars['%PHPCI_BUILD_URI%'] = $this->interpolationVars['%BUILD_URI%'];
|
||||||
|
|
||||||
putenv('PHPCI=1');
|
putenv('PHPCI=1');
|
||||||
putenv('PHPCI_COMMIT=' . $this->interpolation_vars['%COMMIT%']);
|
putenv('PHPCI_COMMIT=' . $this->interpolationVars['%COMMIT%']);
|
||||||
putenv('PHPCI_SHORT_COMMIT=' . $this->interpolation_vars['%SHORT_COMMIT%']);
|
putenv('PHPCI_SHORT_COMMIT=' . $this->interpolationVars['%SHORT_COMMIT%']);
|
||||||
putenv('PHPCI_COMMIT_MESSAGE=' . $this->interpolation_vars['%COMMIT_MESSAGE%']);
|
putenv('PHPCI_COMMIT_MESSAGE=' . $this->interpolationVars['%COMMIT_MESSAGE%']);
|
||||||
putenv('PHPCI_COMMIT_EMAIL=' . $this->interpolation_vars['%COMMIT_EMAIL%']);
|
putenv('PHPCI_COMMIT_EMAIL=' . $this->interpolationVars['%COMMIT_EMAIL%']);
|
||||||
putenv('PHPCI_COMMIT_URI=' . $this->interpolation_vars['%COMMIT_URI%']);
|
putenv('PHPCI_COMMIT_URI=' . $this->interpolationVars['%COMMIT_URI%']);
|
||||||
putenv('PHPCI_PROJECT=' . $this->interpolation_vars['%PROJECT%']);
|
putenv('PHPCI_PROJECT=' . $this->interpolationVars['%PROJECT%']);
|
||||||
putenv('PHPCI_BUILD=' . $this->interpolation_vars['%BUILD%']);
|
putenv('PHPCI_BUILD=' . $this->interpolationVars['%BUILD%']);
|
||||||
putenv('PHPCI_PROJECT_TITLE=' . $this->interpolation_vars['%PROJECT_TITLE%']);
|
putenv('PHPCI_PROJECT_TITLE=' . $this->interpolationVars['%PROJECT_TITLE%']);
|
||||||
putenv('PHPCI_BUILD_PATH=' . $this->interpolation_vars['%BUILD_PATH%']);
|
putenv('PHPCI_BUILD_PATH=' . $this->interpolationVars['%BUILD_PATH%']);
|
||||||
putenv('PHPCI_BUILD_URI=' . $this->interpolation_vars['%BUILD_URI%']);
|
putenv('PHPCI_BUILD_URI=' . $this->interpolationVars['%BUILD_URI%']);
|
||||||
putenv('PHPCI_ENVIRONMENT=' . $this->interpolation_vars['%ENVIRONMENT%']);
|
putenv('PHPCI_ENVIRONMENT=' . $this->interpolationVars['%ENVIRONMENT%']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,8 +78,8 @@ class BuildInterpolator
|
||||||
*/
|
*/
|
||||||
public function interpolate($input)
|
public function interpolate($input)
|
||||||
{
|
{
|
||||||
$keys = array_keys($this->interpolation_vars);
|
$keys = array_keys($this->interpolationVars);
|
||||||
$values = array_values($this->interpolation_vars);
|
$values = array_values($this->interpolationVars);
|
||||||
return str_replace($keys, $values, $input);
|
return str_replace($keys, $values, $input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class CommandExecutor implements CommandExecutorInterface
|
||||||
* @param bool $quiet
|
* @param bool $quiet
|
||||||
* @param bool $verbose
|
* @param bool $verbose
|
||||||
*/
|
*/
|
||||||
public function __construct(BuildLogger $logger, $rootDir, &$quiet = false, &$verbose = false)
|
public function __construct(BuildLogger $logger, $rootDir, $quiet = false, $verbose = false)
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->quiet = $quiet;
|
$this->quiet = $quiet;
|
||||||
|
|
|
@ -34,9 +34,9 @@ class Github
|
||||||
$results[] = $item;
|
$results[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($headers as $header_name => $header) {
|
foreach ($headers as $headerName => $header) {
|
||||||
if (
|
if (
|
||||||
'Link' === $header_name &&
|
'Link' === $headerName &&
|
||||||
preg_match('/^<([^>]+)>; rel="next"/', implode(', ', $header), $r)
|
preg_match('/^<([^>]+)>; rel="next"/', implode(', ', $header), $r)
|
||||||
) {
|
) {
|
||||||
$host = parse_url($r[1]);
|
$host = parse_url($r[1]);
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Lang
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $default_strings = [];
|
protected static $defaultStrings = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific string from the language file.
|
* Get a specific string from the language file.
|
||||||
|
@ -46,8 +46,8 @@ class Lang
|
||||||
if (array_key_exists($string, self::$strings)) {
|
if (array_key_exists($string, self::$strings)) {
|
||||||
$params[0] = self::$strings[$string];
|
$params[0] = self::$strings[$string];
|
||||||
return call_user_func_array('sprintf', $params);
|
return call_user_func_array('sprintf', $params);
|
||||||
} elseif (self::DEFAULT_LANGUAGE !== self::$language && array_key_exists($string, self::$default_strings)) {
|
} elseif (self::DEFAULT_LANGUAGE !== self::$language && array_key_exists($string, self::$defaultStrings)) {
|
||||||
$params[0] = self::$default_strings[$string];
|
$params[0] = self::$defaultStrings[$string];
|
||||||
return call_user_func_array('sprintf', $params);
|
return call_user_func_array('sprintf', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,14 +124,14 @@ class Lang
|
||||||
* Initialise the Language helper, try load the language file for the user's browser or the configured default.
|
* Initialise the Language helper, try load the language file for the user's browser or the configured default.
|
||||||
*
|
*
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
* @param string $language_force
|
* @param string $languageForce
|
||||||
*/
|
*/
|
||||||
public static function init(Config $config, $language_force = null)
|
public static function init(Config $config, $languageForce = null)
|
||||||
{
|
{
|
||||||
self::$default_strings = self::loadLanguage(self::DEFAULT_LANGUAGE);
|
self::$defaultStrings = self::loadLanguage(self::DEFAULT_LANGUAGE);
|
||||||
self::loadAvailableLanguages();
|
self::loadAvailableLanguages();
|
||||||
|
|
||||||
if ($language_force && self::setLanguage($language_force)) {
|
if ($languageForce && self::setLanguage($languageForce)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,10 @@ class Lang
|
||||||
*/
|
*/
|
||||||
protected static function loadLanguage($language = null)
|
protected static function loadLanguage($language = null)
|
||||||
{
|
{
|
||||||
$language = $language ? $language : self::$language;
|
$language = $language
|
||||||
|
? $language
|
||||||
|
: self::$language;
|
||||||
|
|
||||||
$langFile = SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php';
|
$langFile = SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php';
|
||||||
|
|
||||||
if (!file_exists($langFile)) {
|
if (!file_exists($langFile)) {
|
||||||
|
|
|
@ -62,9 +62,9 @@ class Router
|
||||||
//-------
|
//-------
|
||||||
// Set up default values for everything:
|
// Set up default values for everything:
|
||||||
//-------
|
//-------
|
||||||
$thisNamespace = 'Controller';
|
$thisNamespace = 'Controller';
|
||||||
$thisController = null;
|
$thisController = null;
|
||||||
$thisAction = null;
|
$thisAction = null;
|
||||||
|
|
||||||
if (array_key_exists('namespace', $route['defaults'])) {
|
if (array_key_exists('namespace', $route['defaults'])) {
|
||||||
$thisNamespace = $route['defaults']['namespace'];
|
$thisNamespace = $route['defaults']['namespace'];
|
||||||
|
|
|
@ -22,12 +22,12 @@ class BuildDBLogHandler extends AbstractProcessingHandler
|
||||||
/**
|
/**
|
||||||
* @var int last flush timestamp
|
* @var int last flush timestamp
|
||||||
*/
|
*/
|
||||||
protected $flush_timestamp = 0;
|
protected $flushTimestamp = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int flush delay, seconds
|
* @var int flush delay, seconds
|
||||||
*/
|
*/
|
||||||
protected $flush_delay = 1;
|
protected $flushDelay = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Build $build
|
* @param Build $build
|
||||||
|
@ -60,7 +60,7 @@ class BuildDBLogHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
$this->build->setLog($this->logValue);
|
$this->build->setLog($this->logValue);
|
||||||
Factory::getStore('Build')->save($this->build);
|
Factory::getStore('Build')->save($this->build);
|
||||||
$this->flush_timestamp = time();
|
$this->flushTimestamp = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,7 @@ class BuildDBLogHandler extends AbstractProcessingHandler
|
||||||
|
|
||||||
$this->logValue .= $message . PHP_EOL;
|
$this->logValue .= $message . PHP_EOL;
|
||||||
|
|
||||||
if ($this->flush_timestamp < (time() - $this->flush_delay)) {
|
if ($this->flushTimestamp < (time() - $this->flushDelay)) {
|
||||||
$this->flushData();
|
$this->flushData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,10 @@ class Handler
|
||||||
public function handleError($level, $message, $file, $line)
|
public function handleError($level, $message, $file, $line)
|
||||||
{
|
{
|
||||||
if (error_reporting() & $level) {
|
if (error_reporting() & $level) {
|
||||||
$exception_level = isset($this->levels[$level]) ? $this->levels[$level] : $level;
|
$exceptionLevel = isset($this->levels[$level]) ? $this->levels[$level] : $level;
|
||||||
|
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
sprintf('%s: %s in %s line %d', $exception_level, $message, $file, $line),
|
sprintf('%s: %s in %s line %d', $exceptionLevel, $message, $file, $line),
|
||||||
0,
|
0,
|
||||||
$level,
|
$level,
|
||||||
$file,
|
$file,
|
||||||
|
@ -79,22 +79,22 @@ class Handler
|
||||||
*/
|
*/
|
||||||
public function handleFatalError()
|
public function handleFatalError()
|
||||||
{
|
{
|
||||||
$fatal_error = error_get_last();
|
$fatalError = error_get_last();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (($error = error_get_last()) !== null) {
|
if (($error = error_get_last()) !== null) {
|
||||||
$error = new \ErrorException(
|
$error = new \ErrorException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'%s: %s in %s line %d',
|
'%s: %s in %s line %d',
|
||||||
$fatal_error['type'],
|
$fatalError['type'],
|
||||||
$fatal_error['message'],
|
$fatalError['message'],
|
||||||
$fatal_error['file'],
|
$fatalError['file'],
|
||||||
$fatal_error['line']
|
$fatalError['line']
|
||||||
),
|
),
|
||||||
0,
|
0,
|
||||||
$fatal_error['type'],
|
$fatalError['type'],
|
||||||
$fatal_error['file'],
|
$fatalError['file'],
|
||||||
$fatal_error['line']
|
$fatalError['line']
|
||||||
);
|
);
|
||||||
$this->log($error);
|
$this->log($error);
|
||||||
}
|
}
|
||||||
|
@ -102,15 +102,15 @@ class Handler
|
||||||
$error = new \ErrorException(
|
$error = new \ErrorException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'%s: %s in %s line %d',
|
'%s: %s in %s line %d',
|
||||||
$fatal_error['type'],
|
$fatalError['type'],
|
||||||
$fatal_error['message'],
|
$fatalError['message'],
|
||||||
$fatal_error['file'],
|
$fatalError['file'],
|
||||||
$fatal_error['line']
|
$fatalError['line']
|
||||||
),
|
),
|
||||||
0,
|
0,
|
||||||
$fatal_error['type'],
|
$fatalError['type'],
|
||||||
$fatal_error['file'],
|
$fatalError['file'],
|
||||||
$fatal_error['line']
|
$fatalError['line']
|
||||||
);
|
);
|
||||||
$this->log($error);
|
$this->log($error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ class GithubBuild extends GitBuild
|
||||||
$project = $this->getProject();
|
$project = $this->getProject();
|
||||||
|
|
||||||
if (!is_null($project)) {
|
if (!is_null($project)) {
|
||||||
$reference = $project->getReference();
|
$reference = $project->getReference();
|
||||||
$commitLink = '<a href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
|
$commitLink = '<a href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
|
||||||
$rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn);
|
$rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn);
|
||||||
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a href="https://github.com/$1">@$1</a>', $rtn);
|
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a href="https://github.com/$1">@$1</a>', $rtn);
|
||||||
|
|
|
@ -49,9 +49,9 @@ class GitlabBuild extends GitBuild
|
||||||
$key = trim($this->getProject()->getSshPrivateKey());
|
$key = trim($this->getProject()->getSshPrivateKey());
|
||||||
|
|
||||||
if (!empty($key)) {
|
if (!empty($key)) {
|
||||||
$user = $this->getProject()->getAccessInformation("user");
|
$user = $this->getProject()->getAccessInformation("user");
|
||||||
$domain = $this->getProject()->getAccessInformation("domain");
|
$domain = $this->getProject()->getAccessInformation("domain");
|
||||||
$port = $this->getProject()->getAccessInformation('port');
|
$port = $this->getProject()->getAccessInformation('port');
|
||||||
|
|
||||||
$url = $user . '@' . $domain . ':';
|
$url = $user . '@' . $domain . ':';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue