summaryrefslogtreecommitdiff
path: root/classes/config.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-02 08:33:56 +0300
committerAndrew Dolgov <[email protected]>2021-03-02 08:33:56 +0300
commitf195e86be320f49e326293fe0b3077cfba87d548 (patch)
tree6a735c9b2618e3142223b001b93ed38cc57f1675 /classes/config.php
parent84d8b08d1fe1a85f1dee823bdb180921959fb0c6 (diff)
don't rely on exit code when checking version (again)
Diffstat (limited to 'classes/config.php')
-rw-r--r--classes/config.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/classes/config.php b/classes/config.php
index 8761863f5..b373c9266 100644
--- a/classes/config.php
+++ b/classes/config.php
@@ -182,7 +182,7 @@ class Config {
"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);
if (is_resource($proc)) {
@@ -192,13 +192,20 @@ class Config {
$rv["status"] = $status;
- if ($status == 0) {
- list($timestamp, $commit) = explode("-", $stdout);
+ list($check, $timestamp, $commit) = explode("-", $stdout);
+
+ if ($check == "version") {
$rv["version"] = strftime("%y.%m", (int)$timestamp) . "-$commit";
$rv["commit"] = $commit;
$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 {
$rv["version"] = T_sprintf("Git error [RC=%d]: %s", $status, $stderr);
}