forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitlabBuild.php
More file actions
72 lines (63 loc) · 1.88 KB
/
Copy pathGitlabBuild.php
File metadata and controls
72 lines (63 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace PHPCensor\Model\Build;
/**
* Gitlab Build Model
*
* @author André Cianfarani <a.cianfarani@c2is.fr>
*/
class GitlabBuild extends GitBuild
{
/**
* Get link to commit from another source (i.e. Github)
*
* @return string
*/
public function getCommitLink()
{
$domain = $this->getProject()->getAccessInformation('domain');
return '//' . $domain . '/' . $this->getProject()->getReference() . '/commit/' . $this->getCommitId();
}
/**
* Get link to branch from another source (i.e. Github)
*
* @return string
*/
public function getBranchLink()
{
$domain = $this->getProject()->getAccessInformation('domain');
return '//' . $domain . '/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch();
}
/**
* Get link to specific file (and line) in a the repo's branch
*
* @return string|null
*/
public function getFileLinkTemplate()
{
return sprintf(
'//%s/%s/blob/%s/{FILE}#L{LINE}',
$this->getProject()->getAccessInformation('domain'),
$this->getProject()->getReference(),
$this->getCommitId()
);
}
/**
* Get the URL to be used to clone this remote repository.
*/
protected function getCloneUrl()
{
$key = trim($this->getProject()->getSshPrivateKey());
$user = $this->getProject()->getAccessInformation('user');
$domain = $this->getProject()->getAccessInformation('domain');
$port = $this->getProject()->getAccessInformation('port');
if (!empty($key)) {
$url = 'ssh://' . $user . '@' . $domain;
} else {
$url = 'https://' . $domain;
}
if (!empty($port)) {
$url .= ':' . $port;
}
return $url . '/' . $this->getProject()->getReference() . '.git';
}
}