From 3cb0584e9c6009803266fd5ee43eaa7b6b4ed916 Mon Sep 17 00:00:00 2001 From: fsociety Date: Sun, 6 Oct 2024 15:50:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20refactor(changelog):=20streamlin?= =?UTF-8?q?e=20commit=20history=20parsing=20with=20improved=20output=20for?= =?UTF-8?q?mat=20and=20eliminate=20redundancy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/pages/changelog.blade.php | 44 ++++++----------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/resources/views/pages/changelog.blade.php b/resources/views/pages/changelog.blade.php index 4a82a08..ee498d6 100644 --- a/resources/views/pages/changelog.blade.php +++ b/resources/views/pages/changelog.blade.php @@ -14,42 +14,18 @@ name('changelog'); state(['entries' => []]); mount(function () { - // Führen Sie den Git-Befehl aus, um die Commit-Historie zu erhalten - $gitLog = shell_exec('git log --pretty=format:"%h|%an|%ad%n%s%n%b" --date=iso --no-merges'); - - // Parsen Sie die Ausgabe des Git-Befehls - $rawEntries = explode("\n\n", $gitLog); + $output = shell_exec('git log -n1000 --pretty=format:"%H|%s|%an|%ad" --date=format:"%Y-%m-%d %H:%M:%S"'); + $lines = explode("\n", trim($output)); $entries = []; - $uniqueMessages = []; - foreach ($rawEntries as $entry) { - $lines = explode("\n", $entry); - if (count($lines) < 3) { - continue; - } - - $header = explode('|', array_shift($lines)); - if (count($header) !== 3) { - continue; - } - - [$hash, $author, $date] = $header; - $message = implode("\n", $lines); - - // Format the date to a human-readable format - $dateTime = new DateTime($date); - $formattedDate = $dateTime->format('F j, Y, g:i a'); - - // Überprüfen, ob die Nachricht bereits existiert - if (!in_array($message, $uniqueMessages, true)) { - $uniqueMessages[] = $message; - $entries[] = [ - 'hash' => $hash, - 'message' => $message, - 'author' => $author, - 'date' => $formattedDate, - ]; - } + foreach ($lines as $line) { + [$hash, $message, $author, $date] = explode('|', $line); + $entries[] = [ + 'hash' => $hash, + 'message' => $message, + 'author' => $author, + 'date' => $date, + ]; } $this->entries = $entries; });