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() {
$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));
}
}

View File

@ -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 .= " (?)";
}
?>