php-censor/src/Model/Build/GitlabBuild.php

68 lines
1.8 KiB
PHP
Raw Normal View History

2013-08-23 16:05:12 +02:00
<?php
2016-07-19 20:28:11 +02:00
namespace PHPCensor\Model\Build;
2013-08-23 16:05:12 +02:00
/**
* Gitlab Build Model
*
* @author André Cianfarani <a.cianfarani@c2is.fr>
*/
class GitlabBuild extends GitBuild
2013-08-23 16:05:12 +02:00
{
/**
* Get link to commit from another source (i.e. Github)
*/
public function getCommitLink()
{
$domain = $this->getProject()->getAccessInformation("domain");
return '//' . $domain . '/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId();
2013-08-23 16:05:12 +02:00
}
/**
* Get link to branch from another source (i.e. Github)
*/
public function getBranchLink()
{
$domain = $this->getProject()->getAccessInformation("domain");
return '//' . $domain . '/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch();
2013-08-23 16:05:12 +02:00
}
/**
* Get link to specific file (and line) in a the repo's branch
*/
public function getFileLinkTemplate()
{
return sprintf(
'//%s/%s/blob/%s/{FILE}#L{LINE}',
$this->getProject()->getAccessInformation("domain"),
$this->getProject()->getReference(),
$this->getCommitId()
);
}
2013-08-23 16:05:12 +02:00
/**
* Get the URL to be used to clone this remote repository.
*/
protected function getCloneUrl()
{
$key = trim($this->getProject()->getSshPrivateKey());
2013-08-23 16:05:12 +02:00
if (!empty($key)) {
2018-03-05 13:32:49 +01:00
$user = $this->getProject()->getAccessInformation("user");
$domain = $this->getProject()->getAccessInformation("domain");
2018-03-05 13:32:49 +01:00
$port = $this->getProject()->getAccessInformation('port');
$url = $user . '@' . $domain . ':';
if (!empty($port)) {
$url .= $port . '/';
}
$url .= $this->getProject()->getReference() . '.git';
return $url;
2013-08-23 16:05:12 +02:00
}
}
}