Skip to content
Permalink
Browse files

Fixes for new BitbucketServer build type. Issue #260, #286.

  • Loading branch information...
corpsee committed Mar 12, 2019
1 parent 2d4a8d0 commit 074d60946a87a703bb5b5d62d50c1efc2daa7780
@@ -103,10 +103,10 @@ public function view($projectId)
}
/** @var PHPCensor\Model\User $user */
$user = $this->getUser();
$perPage = $user->getFinalPerPage();
$builds = $this->getLatestBuildsHtml($projectId, $branch, $environment, (($page - 1) * $perPage), $perPage);
$pages = ($builds[1] === 0)
$user = $this->getUser();
$perPage = $user->getFinalPerPage();
$builds = $this->getLatestBuildsHtml($projectId, $branch, $environment, (($page - 1) * $perPage), $perPage);
$pages = ($builds[1] === 0)
? 1
: (integer)ceil($builds[1] / $perPage);
@@ -486,17 +486,17 @@ protected function projectForm($values, $type = 'add')
$form->addField(new Form\Element\Hidden('ssh_public_key'));
$options = [
'choose' => Lang::get('select_repository_type'),
Project::TYPE_GITHUB => 'GitHub',
Project::TYPE_BITBUCKET => 'Bitbucket (Git)',
'choose' => Lang::get('select_repository_type'),
Project::TYPE_GITHUB => 'GitHub',
Project::TYPE_BITBUCKET => 'Bitbucket (Git)',
Project::TYPE_BITBUCKET_SERVER => 'Bitbucket (Server)',
Project::TYPE_BITBUCKET_HG => 'Bitbucket (Hg)',
Project::TYPE_GITLAB => 'GitLab',
Project::TYPE_GOGS => 'Gogs',
Project::TYPE_GIT => 'Git',
Project::TYPE_LOCAL => Lang::get('local'),
Project::TYPE_HG => 'Hg (Mercurial)',
Project::TYPE_SVN => 'Svn (Subversion)',
Project::TYPE_BITBUCKET_HG => 'Bitbucket (Hg)',
Project::TYPE_GITLAB => 'GitLab',
Project::TYPE_GOGS => 'Gogs',
Project::TYPE_GIT => 'Git',
Project::TYPE_LOCAL => Lang::get('local'),
Project::TYPE_HG => 'Hg (Mercurial)',
Project::TYPE_SVN => 'Svn (Subversion)',
];
$sourcesPattern = sprintf('^(%s)', implode('|', Project::$allowedTypes));
@@ -147,7 +147,7 @@ function ($a) {
$shouldOutput = ($this->logExecOutput && ($this->verbose || 0 !== $status));
if (($shouldOutput) && !empty($this->lastOutput)) {
if ($shouldOutput && !empty($this->lastOutput)) {
$this->logger->log($this->lastOutput);
}
@@ -7,16 +7,16 @@
class Project extends Model
{
const TYPE_LOCAL = 'local';
const TYPE_GIT = 'git';
const TYPE_GITHUB = 'github';
const TYPE_BITBUCKET = 'bitbucket';
const TYPE_GITLAB = 'gitlab';
const TYPE_GOGS = 'gogs';
const TYPE_HG = 'hg';
const TYPE_BITBUCKET_HG = 'bitbucket-hg';
const TYPE_LOCAL = 'local';
const TYPE_GIT = 'git';
const TYPE_GITHUB = 'github';
const TYPE_BITBUCKET = 'bitbucket';
const TYPE_GITLAB = 'gitlab';
const TYPE_GOGS = 'gogs';
const TYPE_HG = 'hg';
const TYPE_BITBUCKET_HG = 'bitbucket-hg';
const TYPE_BITBUCKET_SERVER = 'bitbucket-server';
const TYPE_SVN = 'svn';
const TYPE_SVN = 'svn';
/**
* @var array
@@ -8,6 +8,7 @@
use PHPCensor\Config;
use PHPCensor\Model\Build;
use PHPCensor\Model\BuildError;
use PHPCensor\Helper\Diff;
/**
* BitBucket Build Model
@@ -313,12 +314,12 @@ protected function getDiffLineNumber(Builder $builder, $file, $line)
$path = $builder->buildPath;
if (!empty($prNumber)) {
$builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
$builder->executeCommand('cd "%s" && git diff "origin/%s" "%s"', $path, $this->getBranch(), $file);
} else {
$commitId = $this->getCommitId();
$compare = empty($commitId) ? 'HEAD' : $commitId;
$builder->executeCommand('cd %s && git diff %s^^ "%s"', $path, $compare, $file);
$builder->executeCommand('cd "%s" && git diff "%s^^" "%s"', $path, $compare, $file);
}
$builder->logExecOutput(true);
@@ -5,12 +5,6 @@
use PHPCensor\Builder;
use PHPCensor\Model\Build;
/**
* BitBucket Build Model
* Derived from BitBucketBuild
* @author Dan Cryer <dan@block8.co.uk>
*
*/
class BitbucketServerBuild extends GitBuild
{
/**
@@ -128,8 +122,8 @@ protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = nul
$success = $builder->executeCommand($cmd, $cloneTo);
if ($success) {
$applycmd = 'git apply "%s"';
$success = $builder->executeCommand($applycmd, $diffFile);
$applyCmd = 'git apply "%s"';
$success = $builder->executeCommand($applyCmd, $diffFile);
}
//unlink($diffFile);
@@ -158,11 +152,12 @@ protected function getPullRequestDiff(Builder $builder, $cloneTo, $targetBranch)
$cmd = 'cd "%s" && git diff %s';
$success = $builder->executeCommand($cmd, $cloneTo, $targetBranch);
if ($success) {
return $builder->getLastOutput();
}
throw new Exception('Unable to create diff patch.');
throw new \Exception('Unable to create diff patch.');
}
/**

0 comments on commit 074d609

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.