From d07e98178e9361372e89d0c9d6537be73294413d Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 21 Jan 2017 00:07:12 +0700 Subject: [PATCH] Fixes --- src/PHPCensor/Model/Build/GithubBuild.php | 35 +++++++++++++---------- src/PHPCensor/Plugin/PhpUnit.php | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/PHPCensor/Model/Build/GithubBuild.php b/src/PHPCensor/Model/Build/GithubBuild.php index a4f2c686..daccdb48 100644 --- a/src/PHPCensor/Model/Build/GithubBuild.php +++ b/src/PHPCensor/Model/Build/GithubBuild.php @@ -202,25 +202,30 @@ class GithubBuild extends RemoteGitBuild $lineStart = null, $lineEnd = null ) { - $diffLineNumber = $this->getDiffLineNumber($builder, $file, $lineStart); + $allowCommentCommit = (boolean)Config::getInstance()->get('php-censor.github.comments.commit', false); + $allowCommentPullRequest = (boolean)Config::getInstance()->get('php-censor.github.comments.pull_request', false); - if (!is_null($diffLineNumber)) { - $helper = new Github(); + if ($allowCommentCommit || $allowCommentPullRequest) { + $diffLineNumber = $this->getDiffLineNumber($builder, $file, $lineStart); - $repo = $this->getProject()->getReference(); - $prNumber = $this->getExtra('pull_request_number'); - $commit = $this->getCommitId(); + if (!is_null($diffLineNumber)) { + $helper = new Github(); - $allowCommentCommit = (boolean)Config::getInstance()->get('php-censor.github.comments.commit', false); - $allowCommentPullRequest = (boolean)Config::getInstance()->get('php-censor.github.comments.pull_request', false); + $repo = $this->getProject()->getReference(); + $prNumber = $this->getExtra('pull_request_number'); + $commit = $this->getCommitId(); - if (!empty($prNumber)) { - if ($allowCommentPullRequest) { - $helper->createPullRequestComment($repo, $prNumber, $commit, $file, $diffLineNumber, $message); - } - } else { - if ($allowCommentCommit) { - $helper->createCommitComment($repo, $commit, $file, $diffLineNumber, $message); + $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); + } + } else { + if ($allowCommentCommit) { + $helper->createCommitComment($repo, $commit, $file, $diffLineNumber, $message); + } } } } diff --git a/src/PHPCensor/Plugin/PhpUnit.php b/src/PHPCensor/Plugin/PhpUnit.php index 49fabb06..014b6337 100644 --- a/src/PHPCensor/Plugin/PhpUnit.php +++ b/src/PHPCensor/Plugin/PhpUnit.php @@ -145,7 +145,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface protected function runConfigFile($configFile) { $options = clone $this->options; - $buildPath = $this->build->getBuildPath() . DIRECTORY_SEPARATOR; + $buildPath = $this->build->getBuildPath(); // Save the results into a json file $jsonFile = tempnam(RUNTIME_DIR, 'jLog_');