blob: 3bb153fec8de8ca1c904291c93f1111ffd44822b (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
<?php
namespace phorkie;
class Repository_Remote
{
protected $arConfig;
protected $name;
public function __construct($name, $arConfig)
{
$this->name = $name;
$this->arConfig = $arConfig;
}
public function getName()
{
return $this->name;
}
public function getTitle()
{
if (isset($this->arConfig['title'])) {
return $this->arConfig['title'];
}
if ($this->isLocal()) {
$local = $this->getLocalRepository();
if ($local !== null) {
return $local->getTitle();
}
return 'deleted local paste';
}
return 'untitled repository';
}
public function getCloneURL()
{
if ($this->isLocal()) {
$local = $this->getLocalRepository();
if ($local !== null) {
return $local->getCloneURL();
}
}
if (isset($this->arConfig['url'])) {
return $this->arConfig['url'];
}
return null;
}
public function getWebURL($full = false)
{
if (isset($this->arConfig['homepage'])) {
return $this->arConfig['homepage'];
}
if ($this->isLocal()) {
$local = $this->getLocalRepository();
if ($local !== null) {
return $local->getLink('display', null, $full);
}
}
return null;
}
/**
* Tells you if this remote repository is a paste on the local server
*
* @return boolean True of false
*/
public function isLocal()
{
return isset($this->arConfig['url'])
&& $this->arConfig['url']{0} == '/';
}
/**
* If this remote is a local paste, then we'll get the repository object
* returned
*
* @return Repository Repository object or NULL
*/
public function getLocalRepository()
{
if (!file_exists($this->arConfig['url'] . '/config')) {
return null;
}
$dir = basename($this->arConfig['url']);
if (substr($dir, -4) != '.git') {
//phorks are bare repositories "123.git"
return null;
}
$repo = new Repository();
$repo->loadById(substr($dir, 0, -4));
return $repo;
}
}
?>
|