1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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>";
}
}
|