Refactored build type 'Pull request' logic.
This commit is contained in:
parent
1623e05593
commit
429405809e
12 changed files with 143 additions and 80 deletions
|
|
@ -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 . '/';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue