diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 47 |
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>"; + } +} |