don't rely on exit code when checking version (again)
This commit is contained in:
parent
84d8b08d1f
commit
f195e86be3
|
@ -182,7 +182,7 @@ class Config {
|
||||||
"timestamp" => 0,
|
"timestamp" => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$proc = proc_open("git --no-pager log --pretty=\"%ct-%h\" -n1 HEAD",
|
$proc = proc_open("git --no-pager log --pretty=\"version-%ct-%h\" -n1 HEAD",
|
||||||
$descriptorspec, $pipes, $dir);
|
$descriptorspec, $pipes, $dir);
|
||||||
|
|
||||||
if (is_resource($proc)) {
|
if (is_resource($proc)) {
|
||||||
|
@ -192,13 +192,20 @@ class Config {
|
||||||
|
|
||||||
$rv["status"] = $status;
|
$rv["status"] = $status;
|
||||||
|
|
||||||
if ($status == 0) {
|
list($check, $timestamp, $commit) = explode("-", $stdout);
|
||||||
list($timestamp, $commit) = explode("-", $stdout);
|
|
||||||
|
if ($check == "version") {
|
||||||
|
|
||||||
$rv["version"] = strftime("%y.%m", (int)$timestamp) . "-$commit";
|
$rv["version"] = strftime("%y.%m", (int)$timestamp) . "-$commit";
|
||||||
$rv["commit"] = $commit;
|
$rv["commit"] = $commit;
|
||||||
$rv["timestamp"] = $timestamp;
|
$rv["timestamp"] = $timestamp;
|
||||||
|
|
||||||
|
// proc_close() may return -1 even if command completed successfully
|
||||||
|
// so if it looks like we got valid data, we ignore it
|
||||||
|
|
||||||
|
if ($rv["status"] == -1)
|
||||||
|
$rv["status"] = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$rv["version"] = T_sprintf("Git error [RC=%d]: %s", $status, $stderr);
|
$rv["version"] = T_sprintf("Git error [RC=%d]: %s", $status, $stderr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue