Skip to content
This repository was archived by the owner on Sep 10, 2023. It is now read-only.

Commit f4dcf20

Browse files
committed
New release : 0.6.0 (Issue neard/neard#343)
1 parent 8f66e5b commit f4dcf20

File tree

8 files changed

+289
-2
lines changed

8 files changed

+289
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Changelog
22

3+
## r4 (2017/12/27)
4+
5+
* New release : 0.6.0 (Issue neard/neard#343)
6+
* Escape `/` while generating repo name
7+
38
## r3 (2016/05/05)
49

510
* Wrong RewriteBase on GitList 0.5.0-r2
611

712
## r2 (2016/04/05)
813

9-
* New bundle : 0.5.0
14+
* New release : 0.5.0
1015

1116
## r1 (2016/04/03)
1217

bin/gitlist0.6.0/.htaccess

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<IfModule mod_rewrite.c>
2+
Options -MultiViews +SymLinksIfOwnerMatch
3+
4+
RewriteEngine On
5+
RewriteBase /gitlist/
6+
7+
RewriteCond %{REQUEST_FILENAME} !-f
8+
RewriteRule ^(.*)$ index.php/$1 [L,NC]
9+
</IfModule>
10+
<Files config.ini>
11+
order allow,deny
12+
deny from all
13+
</Files>

bin/gitlist0.6.0/cache/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

bin/gitlist0.6.0/config.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[git]
2+
client = '~NEARD_LIN_PATH~/tools/git/git2.8.0/bin/git.exe'
3+
repositories[] = ''
4+
5+
[app]
6+
debug = false
7+
cache = false
8+
9+
[filetypes]
10+
; extension = type
11+
; dist = xml
12+
13+
[binary_filetypes]
14+
; extension = true
15+
; svh = false
16+
; map = true
17+

bin/gitlist0.6.0/neard.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gitlistVersion = "0.6.0"
2+
gitlistConf = "config.ini"
3+
4+
bundleRelease = "@RELEASE_VERSION@"
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
<?php
2+
3+
namespace GitList\Git;
4+
5+
use Gitter\Client as BaseClient;
6+
7+
class Client extends BaseClient
8+
{
9+
protected $defaultBranch;
10+
protected $hidden;
11+
protected $projects;
12+
13+
public function __construct($options = null)
14+
{
15+
parent::__construct($options['path']);
16+
$this->setDefaultBranch($options['default_branch']);
17+
$this->setHidden($options['hidden']);
18+
$this->setProjects($options['projects']);
19+
}
20+
21+
public function getRepositoryFromName($paths, $repo)
22+
{
23+
$repositories = $this->getRepositories($paths);
24+
$path = $repositories[$repo]['path'];
25+
26+
return $this->getRepository($path);
27+
}
28+
29+
/**
30+
* Searches for valid repositories on the specified path.
31+
*
32+
* @param array $paths Array of paths where repositories will be searched
33+
*
34+
* @return array Found repositories, containing their name, path and description sorted
35+
* by repository name
36+
*/
37+
public function getRepositories($paths)
38+
{
39+
$allRepositories = [];
40+
41+
foreach ($paths as $path) {
42+
/*$repositories = $this->recurseDirectory($path);
43+
44+
if (empty($repositories)) {
45+
throw new \RuntimeException('There are no GIT repositories in ' . $path);
46+
}
47+
48+
// Use "+" to preserve keys, only a problem with numeric repos.
49+
$allRepositories = $allRepositories + $repositories;*/
50+
51+
// START Neard edit
52+
$name = str_replace(':', '', str_replace('/', '#', $path));
53+
$repositories[$name] = array(
54+
'name' => $name,
55+
'path' => $path,
56+
'description' => file_exists($path . '/.git/description') ? file_get_contents($path . '/.git/description') : ''
57+
);
58+
59+
$allRepositories = array_merge($allRepositories, $repositories);
60+
// END Neard edit
61+
}
62+
63+
$allRepositories = array_unique($allRepositories, SORT_REGULAR);
64+
uksort($allRepositories, function ($k1, $k2) {
65+
return strtolower($k2) < strtolower($k1);
66+
});
67+
68+
return $allRepositories;
69+
}
70+
71+
/**
72+
* Return name of default branch as a string.
73+
*/
74+
public function getDefaultBranch()
75+
{
76+
return $this->defaultBranch;
77+
}
78+
79+
/**
80+
* Overloads the parent::createRepository method for the correct Repository class instance.
81+
*
82+
* {@inheritdoc}
83+
*/
84+
public function createRepository($path, $bare = null)
85+
{
86+
if (file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) {
87+
throw new \RuntimeException('A GIT repository already exists at ' . $path);
88+
}
89+
90+
$repository = new Repository($path, $this);
91+
92+
return $repository->create($bare);
93+
}
94+
95+
/**
96+
* Overloads the parent::getRepository method for the correct Repository class instance.
97+
*
98+
* {@inheritdoc}
99+
*/
100+
public function getRepository($path)
101+
{
102+
if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) {
103+
throw new \RuntimeException('There is no GIT repository at ' . $path);
104+
}
105+
106+
return new Repository($path, $this);
107+
}
108+
109+
/**
110+
* Set default branch as a string.
111+
*
112+
* @param string $branch name of branch to use when repo's HEAD is detached
113+
*
114+
* @return object
115+
*/
116+
protected function setDefaultBranch($branch)
117+
{
118+
$this->defaultBranch = $branch;
119+
120+
return $this;
121+
}
122+
123+
/**
124+
* Get hidden repository list.
125+
*
126+
* @return array List of repositories to hide
127+
*/
128+
protected function getHidden()
129+
{
130+
return $this->hidden;
131+
}
132+
133+
/**
134+
* Set the hidden repository list.
135+
*
136+
* @param array $hidden List of repositories to hide
137+
*
138+
* @return object
139+
*/
140+
protected function setHidden($hidden)
141+
{
142+
$this->hidden = $hidden;
143+
144+
return $this;
145+
}
146+
147+
/**
148+
* Get project list.
149+
*
150+
* @return array List of repositories to show
151+
*/
152+
protected function getProjects()
153+
{
154+
return $this->projects;
155+
}
156+
157+
/**
158+
* Set the shown repository list.
159+
*
160+
* @param array $projects List of repositories to show
161+
*/
162+
protected function setProjects($projects)
163+
{
164+
$this->projects = $projects;
165+
166+
return $this;
167+
}
168+
169+
private function recurseDirectory($path, $topLevel = true)
170+
{
171+
$dir = new \DirectoryIterator($path);
172+
173+
$repositories = [];
174+
175+
foreach ($dir as $file) {
176+
if ($file->isDot()) {
177+
continue;
178+
}
179+
180+
if (strrpos($file->getFilename(), '.') === 0) {
181+
continue;
182+
}
183+
184+
if (!$file->isReadable()) {
185+
continue;
186+
}
187+
188+
if ($file->isDir()) {
189+
$isBare = file_exists($file->getPathname() . '/HEAD');
190+
$isRepository = file_exists($file->getPathname() . '/.git/HEAD');
191+
192+
if ($isRepository || $isBare) {
193+
$hidden = function ($path, $hide) {
194+
$return = false;
195+
196+
array_walk($hide, function ($value, $key) use ($path, &$return) {
197+
if (($path === $value) || (1 === preg_match($value, $path))) {
198+
$return = true;
199+
}
200+
});
201+
202+
return $return;
203+
};
204+
205+
if ($hidden($file->getPathname(), $this->getHidden())) {
206+
continue;
207+
}
208+
209+
if ($isBare) {
210+
$description = $file->getPathname() . '/description';
211+
} else {
212+
$description = $file->getPathname() . '/.git/description';
213+
}
214+
215+
if (file_exists($description)) {
216+
$description = file_get_contents($description);
217+
} else {
218+
$description = null;
219+
}
220+
221+
if (!$topLevel) {
222+
$repoName = $file->getPathInfo()->getFilename() . '/' . $file->getFilename();
223+
} else {
224+
$repoName = $file->getFilename();
225+
}
226+
227+
if (is_array($this->getProjects()) && !in_array($repoName, $this->getProjects())) {
228+
continue;
229+
}
230+
231+
$repositories[$repoName] = [
232+
'name' => $repoName,
233+
'path' => $file->getPathname(),
234+
'description' => $description,
235+
];
236+
237+
continue;
238+
}
239+
$repositories = array_merge($repositories, $this->recurseDirectory($file->getPathname(), false));
240+
}
241+
}
242+
243+
return $repositories;
244+
}
245+
}

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bundle.name = gitlist
2-
bundle.release = r3
2+
bundle.release = r4
33
bundle.type = apps
44
bundle.format = 7z
55

releases.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
0.4.0 = https://github.com/neard/module-gitlist/releases/download/r1/neard-gitlist-0.4.0-r1.zip
22
0.5.0 = https://github.com/neard/module-gitlist/releases/download/r3/neard-gitlist-0.5.0-r3.7z
3+
0.6.0 = https://github.com/neard/module-gitlist/releases/download/r4/neard-gitlist-0.6.0-r4.7z

0 commit comments

Comments
 (0)