From 25c40e3e678c288d00173ea5a421f2e0af3a0cbd Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 3 Jun 2020 12:01:09 -0500 Subject: [PATCH] Add link to Github for each commit in an ebooks short commit history --- lib/Ebook.php | 6 +++--- lib/GitCommit.php | 4 +++- www/ebooks/ebook.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Ebook.php b/lib/Ebook.php index 1a7d0859..c34d43e1 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -124,11 +124,11 @@ class Ebook{ } // Fill in the short history of this repo. - $historyEntries = explode("\n", shell_exec('cd ' . escapeshellarg($this->RepoFilesystemPath) . ' && git log -n5 --pretty=format:"%ct %s"') ?? ''); + $historyEntries = explode("\n", shell_exec('cd ' . escapeshellarg($this->RepoFilesystemPath) . ' && git log -n5 --pretty=format:"%ct %H %s"') ?? ''); foreach($historyEntries as $entry){ - $array = explode(' ', $entry, 2); - $this->GitCommits[] = new GitCommit($array[0], $array[1]); + $array = explode(' ', $entry, 3); + $this->GitCommits[] = new GitCommit($array[0], $array[1], $array[2]); } // Get cover image URLs. diff --git a/lib/GitCommit.php b/lib/GitCommit.php index 921abc92..466d9b23 100644 --- a/lib/GitCommit.php +++ b/lib/GitCommit.php @@ -4,9 +4,11 @@ use Safe\DateTimeImmutable; class GitCommit{ public $Timestamp; public $Message; + public $Hash; - public function __construct(string $unixTimestamp, string $message){ + public function __construct(string $unixTimestamp, string $hash, string $message){ $this->Timestamp = new DateTimeImmutable('@' . $unixTimestamp); $this->Message = $message; + $this->Hash = $hash; } } diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 3575ea1a..463440ff 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -136,7 +136,7 @@ catch(\Exception $ex){ GitCommits as $commit){ ?>
  • -

    Message) ?>

    +

    Message) ?>