Fixed GitHub status API and access to the pull requests of private projects

This commit is contained in:
StudioMaX 2017-06-02 02:20:29 +06:00
parent af156ada5b
commit 0eba8c2cfe
3 changed files with 17 additions and 7 deletions

View file

@ -80,11 +80,11 @@ class GithubBuild extends RemoteGitBuild
break;
}
$url = Config::getInstance()->get('php-censor.url');
$phpCensorUrl = Config::getInstance()->get('php-censor.url');
$params = [
'state' => $status,
'target_url' => $url . '/build/view/' . $this->getId(),
'target_url' => $phpCensorUrl . '/build/view/' . $this->getId(),
'description' => $description,
'context' => 'PHP Censor',
];
@ -163,9 +163,10 @@ class GithubBuild extends RemoteGitBuild
* Handle any post-clone tasks, like applying a pull request patch on top of the branch.
* @param Builder $builder
* @param $cloneTo
* @param array $extra
* @return bool
*/
protected function postCloneSetup(Builder $builder, $cloneTo)
protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null)
{
$buildType = $this->getExtra('build_type');
@ -177,6 +178,9 @@ class GithubBuild extends RemoteGitBuild
$remoteBranch = $this->getExtra('remote_branch');
$cmd = 'cd "%s" && git checkout -b php-censor/' . $this->getId() . ' %s && git pull -q --no-edit %s %s';
if (!empty($extra['git_ssh_wrapper'])) {
$cmd = 'export GIT_SSH="'.$extra['git_ssh_wrapper'].'" && ' . $cmd;
}
$success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch);
}
} catch (\Exception $ex) {
@ -184,7 +188,7 @@ class GithubBuild extends RemoteGitBuild
}
if ($success) {
$success = parent::postCloneSetup($builder, $cloneTo);
$success = parent::postCloneSetup($builder, $cloneTo, $extra);
}
return $success;

View file

@ -79,9 +79,10 @@ class MercurialBuild extends Build
* Handle post-clone tasks (switching branch, etc.)
* @param Builder $builder
* @param $cloneTo
* @param array $extra
* @return bool
*/
protected function postCloneSetup(Builder $builder, $cloneTo)
protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null)
{
$success = true;
$commit = $this->getCommitId();

View file

@ -114,7 +114,11 @@ class RemoteGitBuild extends Build
$success = $builder->executeCommand($cmd, $this->getBranch(), $this->getCloneUrl(), $cloneTo);
if ($success) {
$success = $this->postCloneSetup($builder, $cloneTo);
$extra = [
'git_ssh_wrapper' => $gitSshWrapper
];
$success = $this->postCloneSetup($builder, $cloneTo, $extra);
}
// Remove the key file and git wrapper:
@ -128,9 +132,10 @@ class RemoteGitBuild extends Build
* Handle any post-clone tasks, like switching branches.
* @param Builder $builder
* @param $cloneTo
* @param array $extra
* @return bool
*/
protected function postCloneSetup(Builder $builder, $cloneTo)
protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null)
{
$success = true;
$commit = $this->getCommitId();