mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Show git branch in version info
This commit is contained in:
parent
bc615faf88
commit
067597595d
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
version.php
16
version.php
@ -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 .= " (?)";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user