Merge branch 'feature-commit-status'
This commit is contained in:
commit
a9d247ecb5
|
@ -45,11 +45,15 @@ php-censor:
|
|||
comments:
|
||||
commit: false # This option allow/deny to post comments to Bitbucket commit
|
||||
pull_request: false # This option allow/deny to post comments to Bitbucket Pull Request
|
||||
status:
|
||||
commit: false # This option allow/deny to post status to Bitbucket commit
|
||||
github:
|
||||
token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
comments:
|
||||
commit: false # This option allow/deny to post comments to Github commit
|
||||
pull_request: false # This option allow/deny to post comments to Github Pull Request
|
||||
status:
|
||||
commit: false # This option allow/deny to post status to Github commit
|
||||
build:
|
||||
remove_builds: true # This option allow/deny build cleaning
|
||||
writer_buffer_size: 500 # BuildErrorWriter buffer size (count of inserts in one SQL query)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -44,7 +44,7 @@ class BitbucketBuild extends RemoteGitBuild
|
|||
/**
|
||||
* Send status updates to any relevant third parties (i.e. Bitbucket)
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
|
@ -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);
|
||||
|
|
|
@ -43,6 +43,8 @@ class GithubBuild extends RemoteGitBuild
|
|||
|
||||
/**
|
||||
* Send status updates to any relevant third parties (i.e. Github)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
|
@ -56,11 +58,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:
|
||||
|
@ -83,9 +93,12 @@ class GithubBuild extends RemoteGitBuild
|
|||
|
||||
$phpCensorUrl = Config::getInstance()->get('php-censor.url');
|
||||
|
||||
$url = 'https://api.github.com/repos/' . $project->getReference() . '/statuses/' . $this->getCommitId();
|
||||
$client = new Client();
|
||||
$client->post($url, [
|
||||
$url = '/repos/' . $project->getReference() . '/statuses/' . $this->getCommitId();
|
||||
$client = new Client([
|
||||
'base_uri' => 'https://api.github.com',
|
||||
'http_errors' => false,
|
||||
]);
|
||||
$response = $client->post($url, [
|
||||
'headers' => [
|
||||
'Authorization' => 'token ' . $token,
|
||||
'Content-Type' => 'application/x-www-form-urlencoded'
|
||||
|
@ -98,7 +111,9 @@ class GithubBuild extends RemoteGitBuild
|
|||
]
|
||||
]);
|
||||
|
||||
return true;
|
||||
$status = (integer)$response->getStatusCode();
|
||||
|
||||
return ($status >= 200 && $status < 300);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,8 +222,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 +242,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);
|
||||
|
|
|
@ -130,7 +130,6 @@ class BuildService
|
|||
|
||||
/** @var Build $build */
|
||||
$build = $this->buildStore->save($build);
|
||||
|
||||
$buildId = $build->getId();
|
||||
|
||||
if (!empty($buildId)) {
|
||||
|
|
Loading…
Reference in a new issue