diff options
author | Andrew Dolgov <[email protected]> | 2021-03-01 13:43:37 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-01 13:43:37 +0300 |
commit | 320503dd3911de93d059ebe1ba8b96004d8f6b03 (patch) | |
tree | ce44d5c6b8ed3a6cd54d2bb7dda47445f1b2f688 /classes/pref | |
parent | 20a844085f42975a9e2d20a9cd489a0251d52ad5 (diff) |
move version-related stuff to Config; fix conditional feed requests
Diffstat (limited to 'classes/pref')
-rw-r--r-- | classes/pref/prefs.php | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 565ddaded..5fe4f1bbf 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1099,29 +1099,6 @@ class Pref_Prefs extends Handler_Protected { set_pref(Prefs::_ENABLED_PLUGINS, $plugins); } - function _get_version_from_git(string $dir) { - $descriptorspec = [ - 1 => ["pipe", "w"], // STDOUT - 2 => ["pipe", "w"], // STDERR - ]; - - $proc = proc_open("git --no-pager log --pretty=\"%ct %h\" -n1 HEAD", - $descriptorspec, $pipes, $dir); - - if (is_resource($proc)) { - $stdout = stream_get_contents($pipes[1]); - $stderr = stream_get_contents($pipes[2]); - $status = proc_close($proc); - - if ($status == 0) { - list($timestamp, $commit) = explode(" ", $stdout); - return trim(strftime("%y.%m", (int)$timestamp) . "-$commit"); - } else { - return T_sprintf("Git error [RC=%d]: %s", $status, $stderr); - } - } - } - function _get_plugin_version(Plugin $plugin) { $about = $plugin->about(); @@ -1137,7 +1114,9 @@ class Pref_Prefs extends Handler_Protected { } if (is_dir("$plugin_dir/.git")) { - return T_sprintf("v%s, by %s", $this->_get_version_from_git($plugin_dir), $about[2]); + $ver = Config::get_version_from_git($plugin_dir); + + return $ver["status"] == 0 ? T_sprintf("v%s, by %s", $ver["version"], $about[2]) : $ver["version"]; } } } |