Added pull request remote branch to GUI.

This commit is contained in:
Dmitry Khomutov 2018-02-23 19:31:06 +07:00
parent 429405809e
commit 3400271bc5
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
9 changed files with 118 additions and 22 deletions

View file

@ -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)
*/

View file

@ -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)
*

View file

@ -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.
*

View file

@ -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 = '<a target="_blank" href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
$commitLink = '<a href="https://github.com/' . $reference . '/issues/$1">#$1</a>';
$rtn = preg_replace('/\#([0-9]+)/', $commitLink, $rtn);
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a target="_blank" href="https://github.com/$1">@$1</a>', $rtn);
$rtn = preg_replace('/\@([a-zA-Z0-9_]+)/', '<a href="https://github.com/$1">@$1</a>', $rtn);
}
return $rtn;

View file

@ -24,9 +24,9 @@ foreach ($errors as $error):
</span>
</td>
<td><?= Lang::get($error->getPlugin()); ?></td>
<td><a href="<?php print $link; ?>" target="_blank"><?= $error->getFile(); ?></a></td>
<td><a href="<?= $link; ?>"><?= $error->getFile(); ?></a></td>
<td>
<a href="<?php print $link; ?>" target="_blank">
<a href="<?= $link; ?>">
<?php
if ($error->getLineStart() == $error->getLineEnd() || !$error->getLineEnd()) {
echo $error->getLineStart();

View file

@ -34,11 +34,18 @@ use PHPCensor\Model\BuildError;
<tr>
<th><?php Lang::out('branch'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?>
<?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getRemoteBranch(); ?> :
</a>
<?php endif; ?>
<a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getBranch(); ?>
</a>
<?php if ($tag = $build->getTag()): ?> /
<a target="_blank" href="<?= $build->getTagLink(); ?>">
<a href="<?= $build->getTagLink(); ?>">
<i class="fa fa-tag"></i> <?= $tag; ?>
</a>
<?php endif; ?>
@ -58,7 +65,7 @@ use PHPCensor\Model\BuildError;
<tr>
<th><?php Lang::out('merged_branches'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?= $build->getBranchLink(); ?>">
<a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?>
</a>
+ <?php
@ -97,7 +104,7 @@ use PHPCensor\Model\BuildError;
<tr>
<th><?php Lang::out('commit'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?= $build->getCommitLink(); ?>">
<a href="<?= $build->getCommitLink(); ?>">
<?php print substr($build->getCommitId(), 0, 7); ?>
</a>
</td>

View file

@ -147,7 +147,7 @@
<?php
if (!empty($build->getCommitId())) {
print sprintf(
'<a href="%s" target="_blank">%s %s</a>',
'<a href="%s">%s %s</a>',
$build->getCommitLink(),
substr($build->getCommitId(), 0, 7),
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
@ -160,11 +160,21 @@
<td>
<?php $branches = $build->getExtra('branches'); ?>
<a href="<?= $build->getBranchLink();?>"><i class="fa fa-code-fork"></i> <?php echo $build->getBranch(); ?></a>
<a href="<?= $build->getBranchLink();?>">
<i class="fa fa-code-fork"></i>
<?= $build->getBranch(); ?>
</a>
<?php if (\PHPCensor\Model\Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getRemoteBranch(); ?> :
</a>
<?php endif; ?>
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
<?php if ($tag = $build->getTag()): ?> /
<a href="<?= $build->getTagLink(); ?>" target="_blank">
<i class="fa fa-tag"></i> <?= $tag; ?>
<a href="<?= $build->getTagLink(); ?>">
<i class="fa fa-tag"></i>
<?= $tag; ?>
</a>
<?php endif; ?>
</td>

View file

@ -5,6 +5,7 @@
*/
use PHPCensor\Helper\Lang;
use PHPCensor\Model\Build;
?>
@ -56,7 +57,7 @@ $branches = $build->getExtra('branches');
<?php
if (!empty($build->getCommitId())) {
print sprintf(
'<a href="%s" target="_blank">%s %s</a>',
'<a href="%s">%s %s</a>',
$build->getCommitLink(),
substr($build->getCommitId(), 0, 7),
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
@ -67,13 +68,21 @@ $branches = $build->getExtra('branches');
?>
</td>
<td>
<a href="<?= $build->getBranchLink(); ?>" target="_blank">
<i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?>
<?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getRemoteBranch(); ?> :
</a>
<?php endif; ?>
<a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getBranch(); ?>
</a>
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
<?php if ($tag = $build->getTag()): ?> /
<a href="<?= $build->getTagLink(); ?>" target="_blank">
<i class="fa fa-tag"></i> <?= $tag; ?>
<a href="<?= $build->getTagLink(); ?>">
<i class="fa fa-tag"></i>
<?= $tag; ?>
</a>
<?php endif; ?>
</td>

View file

@ -87,18 +87,29 @@ use PHPCensor\Model\Build;
</h3>
<div class="timeline-body">
<a href="<?= $build->getBranchLink();?>"><i class="fa fa-code-fork"></i> <?php echo $build->getBranch(); ?></a>
<?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getRemoteBranch(); ?> :
</a>
<?php endif; ?>
<a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i>
<?= $build->getBranch(); ?>
</a>
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
<?php if ($tag = $build->getTag()): ?> /
<a href="<?= $build->getTagLink(); ?>" target="_blank">
<i class="fa fa-tag"></i> <?= $tag; ?>
<a href="<?= $build->getTagLink(); ?>">
<i class="fa fa-tag"></i>
<?= $tag; ?>
</a>
<?php endif; ?>
<?php
if (!empty($build->getCommitId())) {
echo ' &mdash; ';
echo sprintf(
'<a href="%s" target="_blank">%s %s</a>',
'<a href="%s">%s %s</a>',
$build->getCommitLink(),
substr($build->getCommitId(), 0, 7),
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''