summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-10-27 19:59:15 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-10-27 19:59:15 +0100
commitb98893f7d8b7ae95955eb7d26921b81818456ce7 (patch)
treee56799cefe358f96b251930fa22e8807353f1778 /index.php
parentb60a706cd38327471dba489bcc100b32c0955a6f (diff)
optimize project findHEADmain
Diffstat (limited to 'index.php')
-rw-r--r--index.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/index.php b/index.php
index 463af36..a5342f8 100644
--- a/index.php
+++ b/index.php
@@ -2,10 +2,11 @@
function find_projects(string $path, array $projects = []): array {
$directories = glob($path . "/{.[!.],}*", GLOB_ONLYDIR | GLOB_BRACE);
- foreach ($directories as $directory) {
- if (str_ends_with($directory, ".git")) {
- $projects[] = substr($directory, 0, -4);
- } else {
+ if (($idx = array_search("$path/.git", $directories)) !== false) {
+ $projects[] = substr($directories[$idx], 0, -4);
+ }
+ else {
+ foreach ($directories as $directory) {
$projects += find_projects($directory, $projects);
}
}