Added config params github.comments.(commit|pull_request) for allow or deny for PHP Censor to commenting on Github

This commit is contained in:
Dmitry Khomutov 2017-01-20 21:55:48 +07:00
commit d209482cda
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
9 changed files with 52 additions and 27 deletions

View file

@ -159,8 +159,8 @@ class Application extends b8\Application
protected function shouldSkipAuth()
{
$config = b8\Config::getInstance();
$state = (bool)$config->get('php-censor.authentication_settings.state', false);
$userId = $config->get('php-censor.authentication_settings.user_id', 0);
$state = (bool)$config->get('php-censor.authentication_settings.state', false);
$userId = $config->get('php-censor.authentication_settings.user_id', 0);
if (false !== $state && 0 != (int)$userId) {
$user = b8\Store\Factory::getStore('User')

View file

@ -20,9 +20,10 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* Create build command - creates a build for a project
* @author Jérémy DECOOL (@jdecool)
* @package PHPCI
* @subpackage Console
*
* @author Jérémy DECOOL (@jdecool)
* @package PHPCI
* @subpackage Console
*/
class CreateBuildCommand extends Command
{

View file

@ -27,9 +27,10 @@ use Symfony\Component\Yaml\Dumper;
/**
* Install console command - Installs PHPCI.
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
class InstallCommand extends Command
{

View file

@ -18,11 +18,12 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Re-runs the last run build.
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
* Re-runs the last run build.
*
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
class RebuildCommand extends Command
{
/**

View file

@ -21,10 +21,10 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
class RebuildQueueCommand extends Command
{
/**

View file

@ -19,11 +19,12 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* Worker Command - Starts the BuildWorker, which pulls jobs from beanstalkd
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
* Worker Command - Starts the BuildWorker, which pulls jobs from beanstalkd
*
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Console
*/
class WorkerCommand extends Command
{
/**

View file

@ -211,10 +211,17 @@ class GithubBuild extends RemoteGitBuild
$prNumber = $this->getExtra('pull_request_number');
$commit = $this->getCommitId();
$allowCommentCommit = Config::getInstance()->get('php-censor.github.comments.commit');
$allowCommentPullRequest = Config::getInstance()->get('php-censor.github.comments.pull_request');
if (!empty($prNumber)) {
$helper->createPullRequestComment($repo, $prNumber, $commit, $file, $diffLineNumber, $message);
if ($allowCommentPullRequest) {
$helper->createPullRequestComment($repo, $prNumber, $commit, $file, $diffLineNumber, $message);
}
} else {
$helper->createCommitComment($repo, $commit, $file, $diffLineNumber, $message);
if ($allowCommentCommit) {
$helper->createCommitComment($repo, $commit, $file, $diffLineNumber, $message);
}
}
}