From 3400271bc54b35aa151233e9c38dc2eda1fa0bdf Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Fri, 23 Feb 2018 19:31:06 +0700 Subject: [PATCH] Added pull request remote branch to GUI. --- src/PHPCensor/Model/Build.php | 16 ++++++++++++++ src/PHPCensor/Model/Build/BitbucketBuild.php | 11 ++++++++++ .../Model/Build/BitbucketHgBuild.php | 21 +++++++++++++++++++ src/PHPCensor/Model/Build/GithubBuild.php | 15 +++++++++++-- src/PHPCensor/View/Build/errors.phtml | 4 ++-- src/PHPCensor/View/Build/view.phtml | 17 ++++++++++----- src/PHPCensor/View/BuildStatus/view.phtml | 18 ++++++++++++---- src/PHPCensor/View/Project/ajax-builds.phtml | 19 ++++++++++++----- .../View/WidgetLastBuilds/update.phtml | 19 +++++++++++++---- 9 files changed, 118 insertions(+), 22 deletions(-) diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index 71403356..bcdf56fc 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -711,6 +711,22 @@ class Build extends Model return '#'; } + /** + * Get remote branch (from pull request) from another source (i.e. Github) + */ + public function getRemoteBranch() + { + return $this->getExtra('remote_branch'); + } + + /** + * Get link to remote branch (from pull request) from another source (i.e. Github) + */ + public function getRemoteBranchLink() + { + return '#'; + } + /** * Get link to tag from another source (i.e. Github) */ diff --git a/src/PHPCensor/Model/Build/BitbucketBuild.php b/src/PHPCensor/Model/Build/BitbucketBuild.php index b56ce4ca..b2ec12ff 100644 --- a/src/PHPCensor/Model/Build/BitbucketBuild.php +++ b/src/PHPCensor/Model/Build/BitbucketBuild.php @@ -37,6 +37,17 @@ class BitbucketBuild extends RemoteGitBuild return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/src/?at=' . $this->getBranch(); } + /** + * Get link to remote branch (from pull request) from another source (i.e. BitBucket) + */ + public function getRemoteBranchLink() + { + $remoteBranch = $this->getExtra('remote_branch'); + $remoteReference = $this->getExtra('remote_reference'); + + return 'https://bitbucket.org/' . $remoteReference . '/src/?at=' . $remoteBranch; + } + /** * Get link to tag from another source (i.e. BitBucket) * diff --git a/src/PHPCensor/Model/Build/BitbucketHgBuild.php b/src/PHPCensor/Model/Build/BitbucketHgBuild.php index d67dd2d8..6be40937 100644 --- a/src/PHPCensor/Model/Build/BitbucketHgBuild.php +++ b/src/PHPCensor/Model/Build/BitbucketHgBuild.php @@ -31,6 +31,27 @@ class BitbucketHgBuild extends MercurialBuild return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/src/?at=' . $this->getBranch(); } + /** + * Get link to remote branch (from pull request) from another source (i.e. BitBucket) + */ + public function getRemoteBranchLink() + { + $remoteBranch = $this->getExtra('remote_branch'); + $remoteReference = $this->getExtra('remote_reference'); + + return 'https://bitbucket.org/' . $remoteReference . '/src/?at=' . $remoteBranch; + } + + /** + * Get link to tag from another source (i.e. BitBucket) + * + * @return string + */ + public function getTagLink() + { + return 'https://bitbucket.org/' . $this->getProject()->getReference() . '/src/?at=' . $this->getTag(); + } + /** * Get the URL to be used to clone this remote repository. * diff --git a/src/PHPCensor/Model/Build/GithubBuild.php b/src/PHPCensor/Model/Build/GithubBuild.php index 911ade0c..be2b5d31 100644 --- a/src/PHPCensor/Model/Build/GithubBuild.php +++ b/src/PHPCensor/Model/Build/GithubBuild.php @@ -37,6 +37,17 @@ class GithubBuild extends RemoteGitBuild return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch(); } + /** + * Get link to remote branch (from pull request) from another source (i.e. Github) + */ + public function getRemoteBranchLink() + { + $remoteBranch = $this->getExtra('remote_branch'); + $remoteReference = $this->getExtra('remote_reference'); + + return 'https://github.com/' . $remoteReference . '/tree/' . $remoteBranch; + } + /** * Get link to tag from another source (i.e. Github) * @@ -151,9 +162,9 @@ class GithubBuild extends RemoteGitBuild if (!is_null($project)) { $reference = $project->getReference(); - $commitLink = '#$1'; + $commitLink = '#$1'; $rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn); - $rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '@$1', $rtn); + $rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '@$1', $rtn); } return $rtn; diff --git a/src/PHPCensor/View/Build/errors.phtml b/src/PHPCensor/View/Build/errors.phtml index b5c080b3..09b068a2 100644 --- a/src/PHPCensor/View/Build/errors.phtml +++ b/src/PHPCensor/View/Build/errors.phtml @@ -24,9 +24,9 @@ foreach ($errors as $error): getPlugin()); ?> - getFile(); ?> + getFile(); ?> - + getLineStart() == $error->getLineEnd() || !$error->getLineEnd()) { echo $error->getLineStart(); diff --git a/src/PHPCensor/View/Build/view.phtml b/src/PHPCensor/View/Build/view.phtml index 0707c253..da5f627a 100644 --- a/src/PHPCensor/View/Build/view.phtml +++ b/src/PHPCensor/View/Build/view.phtml @@ -34,11 +34,18 @@ use PHPCensor\Model\BuildError; - - getBranch(); ?> + getSource()): ?> + + + getRemoteBranch(); ?> : + + + + + getBranch(); ?> getTag()): ?> / - + @@ -58,7 +65,7 @@ use PHPCensor\Model\BuildError; - + getBranch(); ?> + - + getCommitId(), 0, 7); ?> diff --git a/src/PHPCensor/View/BuildStatus/view.phtml b/src/PHPCensor/View/BuildStatus/view.phtml index fb4422a8..e92769e9 100644 --- a/src/PHPCensor/View/BuildStatus/view.phtml +++ b/src/PHPCensor/View/BuildStatus/view.phtml @@ -147,7 +147,7 @@ getCommitId())) { print sprintf( - '%s %s', + '%s %s', $build->getCommitLink(), substr($build->getCommitId(), 0, 7), $build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : '' @@ -160,11 +160,21 @@ getExtra('branches'); ?> - getBranch(); ?> + + + getBranch(); ?> + + getSource()): ?> + + + getRemoteBranch(); ?> : + + getTag()): ?> / - - + + + diff --git a/src/PHPCensor/View/Project/ajax-builds.phtml b/src/PHPCensor/View/Project/ajax-builds.phtml index 940aeeda..68c62af0 100644 --- a/src/PHPCensor/View/Project/ajax-builds.phtml +++ b/src/PHPCensor/View/Project/ajax-builds.phtml @@ -5,6 +5,7 @@ */ use PHPCensor\Helper\Lang; +use PHPCensor\Model\Build; ?> @@ -56,7 +57,7 @@ $branches = $build->getExtra('branches'); getCommitId())) { print sprintf( - '%s %s', + '%s %s', $build->getCommitLink(), substr($build->getCommitId(), 0, 7), $build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : '' @@ -67,13 +68,21 @@ $branches = $build->getExtra('branches'); ?> - - getBranch(); ?> + getSource()): ?> + + + getRemoteBranch(); ?> : + + + + + getBranch(); ?> getTag()): ?> / - - + + + diff --git a/src/PHPCensor/View/WidgetLastBuilds/update.phtml b/src/PHPCensor/View/WidgetLastBuilds/update.phtml index 9c0f48b2..b07bdb80 100644 --- a/src/PHPCensor/View/WidgetLastBuilds/update.phtml +++ b/src/PHPCensor/View/WidgetLastBuilds/update.phtml @@ -87,18 +87,29 @@ use PHPCensor\Model\Build;
- getBranch(); ?> + getSource()): ?> + + + getRemoteBranch(); ?> : + + + + + + getBranch(); ?> + getTag()): ?> / - - + + + getCommitId())) { echo ' — '; echo sprintf( - '%s %s', + '%s %s', $build->getCommitLink(), substr($build->getCommitId(), 0, 7), $build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''