From 067597595d9a09c6418fa807e164dc5436727f7a Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 2 Jun 2024 13:27:51 +0200 Subject: [PATCH] Show git branch in version info --- phpwf/plugins/class.acl.php | 10 ++++++---- version.php | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/phpwf/plugins/class.acl.php b/phpwf/plugins/class.acl.php index df419fe4..59315a18 100644 --- a/phpwf/plugins/class.acl.php +++ b/phpwf/plugins/class.acl.php @@ -1313,6 +1313,7 @@ Allow from all } function refresh_githash() { + $gitinfo = array(); $path = '../.git/'; if (!is_dir($path)) { return; @@ -1321,12 +1322,13 @@ Allow from all $refs = trim(substr($head,0,4)); if ($refs == 'ref:') { $ref = substr($head,5); - $hash = trim(file_get_contents($path . $ref)); + $gitinfo['hash'] = trim(file_get_contents($path . $ref)); + $gitinfo['branch'] = basename($path . $ref); } else { - $hash = $head; + $gitinfo['hash'] = $head; } - if (!empty($hash)) { - file_put_contents("../githash.txt", $hash); + if (!empty($gitinfo)) { + file_put_contents("../gitinfo.json", json_encode($gitinfo)); } } diff --git a/version.php b/version.php index 2b810c37..2553c804 100755 --- a/version.php +++ b/version.php @@ -2,9 +2,19 @@ $version="OSS"; $version_revision="1.11"; -$githash = file_get_contents("../githash.txt"); -if (!empty($githash)) { - $version_revision .= " (".substr($githash,0,8).")"; +$gitinfo = file_get_contents("../gitinfo.json"); +if (!empty($gitinfo)) { + $gitinfo = json_decode($gitinfo); + + if ($gitinfo->branch != 'master') { + $version_revision .= " (".substr($gitinfo->hash,0,8)." - ".$gitinfo->branch.")"; + } + else { + $version_revision .= " (".substr($gitinfo->hash,0,8).")"; + } + +} else { + $version_revision .= " (?)"; } ?>