You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
<?php
|
|
function getRepositories () {
|
|
global $config;
|
|
$repositories = array();
|
|
|
|
if (isset($config['repositories'])) {
|
|
$repositories = $config['repositories'];
|
|
}
|
|
else {
|
|
$repositories = array(
|
|
'default' => array(
|
|
'path' => $config['categoriesDir'],
|
|
),
|
|
);
|
|
}
|
|
|
|
if (isset($config['repositories_gitea'])) {
|
|
$d1 = opendir($config['repositories_gitea']);
|
|
while ($f1 = readdir($d1)) {
|
|
if (substr($f1, 0, 1) !== '.') {
|
|
$d2 = opendir("{$config['repositories_gitea']}/{$f1}");
|
|
while ($f2 = readdir($d2)) {
|
|
if (substr($f2, 0, 1) !== '.') {
|
|
$f2id = substr($f2, 0, -4);
|
|
|
|
$repositories["{$f1}.{$f2id}"] = array(
|
|
'path' => "{$p}/{$f1}/{$f2}",
|
|
'type' => 'git',
|
|
);
|
|
}
|
|
}
|
|
closedir($d2);
|
|
}
|
|
}
|
|
closedir($d1);
|
|
}
|
|
|
|
return $repositories;
|
|
}
|
|
|
|
function getRepo ($repoId, $repoData) {
|
|
switch (array_key_exists('type', $repoData) ? $repoData['type'] : 'dir') {
|
|
case 'git':
|
|
$repo = new RepositoryGit($repoId, $repoData);
|
|
break;
|
|
default:
|
|
$repo = new RepositoryDir($repoId, $repoData);
|
|
}
|
|
|
|
return $repo;
|
|
}
|