1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 19:05:55 +00:00

move version-related stuff to Config; fix conditional feed requests

This commit is contained in:
Andrew Dolgov
2021-03-01 13:43:37 +03:00
parent 20a844085f
commit 320503dd39
11 changed files with 97 additions and 115 deletions

View File

@@ -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"];
}
}
}