Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Moves responsibilities

AuthorDave Jarvis <email>
Date2026-02-09 00:24:27 GMT-0800
Commitede694c6b513fcca8eaf6f0a824409ea95995992
Parent5ce3bf0
Git.php
}
- public function eachRepository(callable $callback): void {
- if (!is_dir($this->path)) return;
- $repos = [];
- foreach (glob($this->path . '/*.git') as $path) {
- if (is_dir($path)) {
- $name = basename($path, '.git');
- $repos[$name] = ['path' => $path, 'name' => urldecode($name), 'safe_name' => $name];
- }
- }
- uasort($repos, fn($a, $b) => strcasecmp($a['name'], $b['name']));
- foreach ($repos as $repo) $callback($repo);
- }
-
public function getMainBranch(): ?array {
$branches = [];
$entrySha = bin2hex(substr($data, $null + 1, 20));
- // Calculate logic internally to encapsulate File creation
$isDir = ($mode === '40000' || $mode === '040000');
$size = $isDir ? 0 : $this->getObjectSize($entrySha);
RepositoryList.php
}
- public function foreach(callable $callback): void {
+ public function eachRepository(callable $callback): void {
if (!is_dir($this->rootPath)) return;
index.php
require_once 'Page.php';
require_once 'Router.php';
+require_once 'RepositoryList.php';
Config::init();
-$repoRoot = new Git(Config::getReposPath());
$repositories = [];
-$repoRoot->eachRepository(function($repo) use (&$repositories) {
+$list = new RepositoryList(Config::getReposPath());
+$list->eachRepository(function($repo) use (&$repositories) {
$repositories[] = $repo;
});
Delta4 lines added, 17 lines removed, 13-line decrease