From 5e25476e8eb1beaca1cbc2637e767516a153e02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 10 Apr 2022 16:18:06 +0200 Subject: [PATCH] RepositoryGit.isEmpty(): return true if timestamp is null or no json/html files --- src/RepositoryGit.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index 59e05fbf..23865108 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -24,9 +24,25 @@ class RepositoryGit extends RepositoryBase { } function timestamp () { - $ts = (int)shell_exec("cd " . escapeShellArg($this->path) . "; git log -1 --all --pretty=format:%ct"); + if (!isset($this->_timestamp)) { + $ts = shell_exec("cd " . escapeShellArg($this->path) . "; git log -1 --all --pretty=format:%ct"); - return $ts; + $this->_timestamp = $ts === null ? null : (int)$ts; + } + + return $this->_timestamp; + } + + function isEmpty () { + if ($this->timestamp() === null) { + return true; + } + + if (!sizeof($this->scandir('.'))) { + return true; + } + + return false; } function data ($options) {