summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-10-23 12:34:40 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-10-23 12:34:40 +0200
commitbf24c721a3f49cc0b8ac87bca3b5c66b329e67bb (patch)
treeae6d6f63c17f87dfe1ddb4a908870bd4e672e839 /index.php
initial commit
Diffstat (limited to 'index.php')
-rw-r--r--index.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..e186d67
--- /dev/null
+++ b/index.php
@@ -0,0 +1,47 @@
+<?php
+
+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 {
+ $projects += find_projects($directory, $projects);
+ }
+ }
+
+ return $projects;
+}
+
+$projects_path = realpath($_GET['projects']);
+$projects = find_projects($projects_path);
+
+function parse_log(): array|null {
+ $proxy = md5(strval(microtime(true)));
+ $process = proc_open(
+ "git log " . "--pretty=format:'{%n {$proxy}commit{$proxy}: {$proxy}%H{$proxy},%n {$proxy}author{$proxy}: {$proxy}%aN <%aE>{$proxy},%n {$proxy}date{$proxy}: {$proxy}%ad{$proxy},%n {$proxy}message{$proxy}: {$proxy}%s{$proxy}%n},'",
+ [
+ ["pipe", "r"],
+ ["pipe", "w"],
+ ["pipe", "w"],
+ ],
+ $pipes
+ );
+
+ $output = stream_get_contents($pipes[1]);
+ $string = str_replace(['"', $proxy], ['\\"', '"'], $output);
+ $string = "[" . rtrim($string, ",") . "]";
+
+ $json = json_decode($string, true);
+
+ return $json;
+}
+
+foreach ($projects as $project) {
+ chdir($project);
+
+ echo $project . "<br>";
+ foreach (parse_log() as $commit) {
+ echo "<a href=\"$commit[commit]\">$commit[message]</a><br>";
+ }
+}