Refactored build type 'Pull request' logic.

This commit is contained in:
Dmitry Khomutov 2018-02-23 17:40:56 +07:00
commit 429405809e
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
12 changed files with 143 additions and 80 deletions

View file

@ -2,15 +2,19 @@
namespace PHPCensor\Model\Build;
use PHPCensor\Model\Build;
/**
* BitBucket Build Model
*
* BitbucketHgBuild Build Model
*
* @author Artem Bochkov <artem.v.bochkov@gmail.com>
*/
class BitbucketHgBuild extends MercurialBuild
{
/**
* Get link to commit from another source (i.e. BitBucket)
*
* @return string
*/
public function getCommitLink()
{
@ -19,6 +23,8 @@ class BitbucketHgBuild extends MercurialBuild
/**
* Get link to branch from another source (i.e. BitBucket)
*
* @return string
*/
public function getBranchLink()
{
@ -27,6 +33,8 @@ class BitbucketHgBuild extends MercurialBuild
/**
* Get the URL to be used to clone this remote repository.
*
* @return string
*/
protected function getCloneUrl()
{
@ -48,11 +56,8 @@ class BitbucketHgBuild extends MercurialBuild
{
$reference = $this->getProject()->getReference();
if ($this->getExtra('build_type') == 'pull_request') {
$matches = [];
preg_match('/[\/:]([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)/', $this->getExtra('remote_url'), $matches);
$reference = $matches[1];
if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $this->getSource()) {
$reference = $this->getExtra('remote_reference');
}
$link = 'https://bitbucket.org/' . $reference . '/';