Show git branch in version info

This commit is contained in:
OpenXE 2024-06-02 13:27:51 +02:00
parent bc615faf88
commit 067597595d
2 changed files with 19 additions and 7 deletions

View File

@ -1313,6 +1313,7 @@ Allow from all
} }
function refresh_githash() { function refresh_githash() {
$gitinfo = array();
$path = '../.git/'; $path = '../.git/';
if (!is_dir($path)) { if (!is_dir($path)) {
return; return;
@ -1321,12 +1322,13 @@ Allow from all
$refs = trim(substr($head,0,4)); $refs = trim(substr($head,0,4));
if ($refs == 'ref:') { if ($refs == 'ref:') {
$ref = substr($head,5); $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 { } else {
$hash = $head; $gitinfo['hash'] = $head;
} }
if (!empty($hash)) { if (!empty($gitinfo)) {
file_put_contents("../githash.txt", $hash); file_put_contents("../gitinfo.json", json_encode($gitinfo));
} }
} }

View File

@ -2,9 +2,19 @@
$version="OSS"; $version="OSS";
$version_revision="1.11"; $version_revision="1.11";
$githash = file_get_contents("../githash.txt"); $gitinfo = file_get_contents("../gitinfo.json");
if (!empty($githash)) { if (!empty($gitinfo)) {
$version_revision .= " (".substr($githash,0,8).")"; $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 .= " (?)";
} }
?> ?>