diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index 16e2537a..10e30307 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -22,7 +22,7 @@ use Symfony\Component\Yaml\Dumper; /** * Install console command - Installs PHP Censor - * + * * @author Dan Cryer */ class InstallCommand extends Command @@ -61,7 +61,7 @@ class InstallCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $configFromFile = (boolean)$input->getOption('config-from-file'); - + if (!$configFromFile && !$this->verifyNotInstalled($output)) { return; } @@ -272,6 +272,9 @@ class InstallCommand extends Command 'commit' => false, 'pull_request' => false, ], + 'status' => [ + 'commit' => false, + ], ], 'github' => [ 'token' => null, @@ -279,6 +282,9 @@ class InstallCommand extends Command 'commit' => false, 'pull_request' => false, ], + 'status' => [ + 'commit' => false, + ], ], 'build' => [ 'remove_builds' => true, @@ -320,7 +326,7 @@ class InstallCommand extends Command 'name' => null, 'lifetime' => 600, ]; - + if (!$input->getOption('queue-use')) { return $skipQueueConfig; } @@ -348,7 +354,7 @@ class InstallCommand extends Command $questionQueue = new Question('Enter your beanstalkd hostname [localhost]: ', 'localhost'); $queueConfig['host'] = $helper->ask($input, $output, $questionQueue); - + $questionName = new Question('Enter the queue (tube) name to use [php-censor-queue]: ', 'php-censor-queue'); $queueConfig['name'] = $helper->ask($input, $output, $questionName); } diff --git a/src/PHPCensor/Model/Build/BitbucketBuild.php b/src/PHPCensor/Model/Build/BitbucketBuild.php index aea525e0..b6a7b8e4 100644 --- a/src/PHPCensor/Model/Build/BitbucketBuild.php +++ b/src/PHPCensor/Model/Build/BitbucketBuild.php @@ -64,6 +64,15 @@ class BitbucketBuild extends RemoteGitBuild return false; } + $allowStatusCommit = (boolean)Config::getInstance()->get( + 'php-censor.bitbucket.status.commit', + false + ); + + if (!$allowStatusCommit) { + return false; + } + switch ($this->getStatus()) { case 0: case 1: @@ -224,8 +233,16 @@ class BitbucketBuild extends RemoteGitBuild $lineStart = null, $lineEnd = null ) { - $allowCommentCommit = (boolean)Config::getInstance()->get('php-censor.bitbucket.comments.commit', false); - $allowCommentPullRequest = (boolean)Config::getInstance()->get('php-censor.bitbucket.comments.pull_request', false); + $allowCommentCommit = (boolean)Config::getInstance()->get( + 'php-censor.bitbucket.comments.commit', + false + ); + + $allowCommentPullRequest = (boolean)Config::getInstance()->get( + 'php-censor.bitbucket.comments.pull_request', + false + ); + //$file = $builder->buildPath.'test.php'; if ($allowCommentCommit || $allowCommentPullRequest) { $diffLineNumber = $this->getDiffLineNumber($builder, $file, $lineStart); diff --git a/src/PHPCensor/Model/Build/GithubBuild.php b/src/PHPCensor/Model/Build/GithubBuild.php index f907e5d9..524dffc4 100644 --- a/src/PHPCensor/Model/Build/GithubBuild.php +++ b/src/PHPCensor/Model/Build/GithubBuild.php @@ -56,11 +56,19 @@ class GithubBuild extends RemoteGitBuild } $token = Config::getInstance()->get('php-censor.github.token'); - if (empty($token) || empty($this->data['id'])) { return false; } + $allowStatusCommit = (boolean)Config::getInstance()->get( + 'php-censor.github.status.commit', + false + ); + + if (!$allowStatusCommit) { + return false; + } + switch ($this->getStatus()) { case 0: case 1: @@ -207,8 +215,15 @@ class GithubBuild extends RemoteGitBuild $lineStart = null, $lineEnd = null ) { - $allowCommentCommit = (boolean)Config::getInstance()->get('php-censor.github.comments.commit', false); - $allowCommentPullRequest = (boolean)Config::getInstance()->get('php-censor.github.comments.pull_request', false); + $allowCommentCommit = (boolean)Config::getInstance()->get( + 'php-censor.github.comments.commit', + false + ); + + $allowCommentPullRequest = (boolean)Config::getInstance()->get( + 'php-censor.github.comments.pull_request', + false + ); if ($allowCommentCommit || $allowCommentPullRequest) { $diffLineNumber = $this->getDiffLineNumber($builder, $file, $lineStart); @@ -220,9 +235,6 @@ class GithubBuild extends RemoteGitBuild $prNumber = $this->getExtra('pull_request_number'); $commit = $this->getCommitId(); - $allowCommentCommit = (boolean)Config::getInstance()->get('php-censor.github.comments.commit', false); - $allowCommentPullRequest = (boolean)Config::getInstance()->get('php-censor.github.comments.pull_request', false); - if (!empty($prNumber)) { if ($allowCommentPullRequest) { $helper->createPullRequestComment($repo, $prNumber, $commit, $file, $diffLineNumber, $message); diff --git a/src/PHPCensor/Service/BuildService.php b/src/PHPCensor/Service/BuildService.php index 6ebffa46..fa06c506 100644 --- a/src/PHPCensor/Service/BuildService.php +++ b/src/PHPCensor/Service/BuildService.php @@ -129,8 +129,7 @@ class BuildService $build->setStatus(Build::STATUS_PENDING); /** @var Build $build */ - $build = $this->buildStore->save($build); - + $build = $this->buildStore->save($build); $buildId = $build->getId(); if (!empty($buildId)) {