Fixes for build branches with special chars (like '#, /' etc.)

This commit is contained in:
Dmitry Khomutov 2017-05-09 11:25:16 +07:00
parent 446deca0cb
commit 6330e3b177
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
2 changed files with 15 additions and 11 deletions

View file

@ -129,16 +129,18 @@ class ProjectController extends PHPCensor\Controller
* Create a new pending build for a project.
*
* @param integer $projectId
* @param string $type Build type: 'environment'|'branch'
* @param string $id Build type id: environment name or branch name
*
* @throws NotFoundException
*
* @return b8\Http\Response\RedirectResponse
*
*/
public function build($projectId, $type = null, $id = null)
public function build($projectId)
{
$type = $this->getParam('type', 'branch');
$id = $this->getParam('id', 'master');
$debug = (boolean)$this->getParam('debug', false);
/* @var \PHPCensor\Model\Project $project */
$project = $this->projectStore->getById($projectId);
$environment = null;
@ -161,7 +163,6 @@ class ProjectController extends PHPCensor\Controller
$branch = $project->getBranch();
}
$debug = (boolean)$this->getParam('debug', false);
$extra = null;
if ($debug && $this->currentUserIsAdmin()) {
@ -175,7 +176,7 @@ class ProjectController extends PHPCensor\Controller
$project,
$environment,
null,
urldecode($branch),
$branch,
null,
$email,
null,

View file

@ -16,34 +16,37 @@
<?php Lang::out('delete_project'); ?>
</a>
<?php
$build_url = APP_URL . 'project/build/' . $project->getId();
?>
<div class="pull-right btn-group">
<?php if (!$project->getArchived()): ?>
<?php if ($this->User()->getIsAdmin()): ?>
<?php if (!empty($environment)): ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/environment/<?= urlencode($environment); ?>?debug=1">
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment, 'debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php elseif (!empty($branch)): ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/branch/<?= urlencode($branch); ?>?debug=1">
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch, 'debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php else: ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>?debug=1">
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?>
</a>
<?php endif; ?>
<?php endif; ?>
<?php if (!empty($environment)): ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/environment/<?= urlencode($environment); ?>">
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment]); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php elseif (!empty($branch)): ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>/branch/<?= urlencode($branch); ?>">
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch]); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php else: ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?>">
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['debug' => 1]); ?>">
<?php Lang::out('build_now'); ?>
</a>
<?php endif; ?>