summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-01-14 20:50:40 +0300
committerAndrew Dolgov <[email protected]>2020-01-14 20:50:40 +0300
commit5fc499e19ef25f9d75994a91aa8589544e5c8421 (patch)
tree48fad5369339a5edd78d3dd6873730142f6e7046
parentf47998f569dd90a803d357bcc353219dc84c7299 (diff)
get_version: don't rely on exec() exit code to determine whether output is valid
-rw-r--r--include/functions.php21
-rw-r--r--prefs.php7
2 files changed, 18 insertions, 10 deletions
diff --git a/include/functions.php b/include/functions.php
index 537139d18..2bdab8ed8 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1889,12 +1889,13 @@
directory, its contents are displayed instead of git commit-based version, this could be generated
based on source git tree commit used when creating the package */
- function get_version(&$git_commit = false, &$git_timestamp = false) {
+ function get_version(&$git_commit = false, &$git_timestamp = false, &$last_error = false) {
global $ttrss_version;
if (is_array($ttrss_version) && isset($ttrss_version['version'])) {
$git_commit = $ttrss_version['commit'];
$git_timestamp = $ttrss_version['timestamp'];
+ $last_error = $ttrss_version['last_error'];
return $ttrss_version['version'];
} else {
@@ -1919,13 +1920,13 @@
$cwd = getcwd();
chdir($root_dir);
- exec('git log --pretty='.escapeshellarg('%ct %h').' -n1 HEAD 2>&1', $output, $rc);
+ exec('git --no-pager log --pretty='.escapeshellarg('version: %ct %h').' -n1 HEAD 2>&1', $output, $rc);
chdir($cwd);
- if ($rc == 0) {
- if (is_array($output) && count($output) > 0) {
- list ($timestamp, $commit) = explode(" ", $output[0], 2);
+ if (is_array($output) && count($output) > 0) {
+ list ($test, $timestamp, $commit) = explode(" ", $output[0], 3);
+ if ($test == "version:") {
$git_commit = $commit;
$git_timestamp = $timestamp;
@@ -1933,8 +1934,14 @@
$ttrss_version['commit'] = $commit;
$ttrss_version['timestamp'] = $timestamp;
}
- } else {
- user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING);
+ }
+
+ if (!isset($ttrss_version['commit'])) {
+ $last_error = "Unable to determine version (using $root_dir): RC=$rc; OUTPUT=" . implode("\n", $output);
+
+ $ttrss_version["last_error"] = $last_error;
+
+ user_error($last_error, E_USER_WARNING);
}
}
diff --git a/prefs.php b/prefs.php
index 7d6962004..22921b23f 100644
--- a/prefs.php
+++ b/prefs.php
@@ -157,9 +157,10 @@
"hook_prefs_tabs", false);
?>
</div>
- <div id="footer" dojoType="dijit.layout.ContentPane" region="bottom">
- <a class="text-muted" target="_blank" href="http://tt-rss.org/">
- Tiny Tiny RSS</a> v<?php echo get_version() ?>
+ <?php $version = get_version($git_commit, $git_timestamp, $last_error); ?>
+ <div id="footer" dojoType="dijit.layout.ContentPane" region="bottom">
+ <a class="text-muted" target="_blank" href="http://tt-rss.org/">Tiny Tiny RSS</a>
+ <span title="<?php echo htmlspecialchars($last_error) ?>">v<?php echo $version ?></span>
&copy; 2005-<?php echo date('Y') ?>
<a class="text-muted" target="_blank"
href="http://fakecake.org/">Andrew Dolgov</a>