summaryrefslogtreecommitdiff
path: root/include/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-12-18 14:27:40 +0300
committerAndrew Dolgov <[email protected]>2019-12-18 14:27:40 +0300
commit72d0fac80c0d88d015203578007260c338b40ece (patch)
treeef8180d43cb63a1236cae4c60e1381bc06d90f20 /include/functions.php
parent10aabfcd09958b6e7ac5a814c96e08a190990b08 (diff)
remove version.php and VERSION global constant, do version-related things in a slightly less ridiculous way
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php41
1 files changed, 40 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php
index 9cd352833..e72a70c13 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -151,7 +151,6 @@
}
require_once 'db-prefs.php';
- require_once 'version.php';
require_once 'controls.php';
define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
@@ -1882,3 +1881,43 @@
return $ts;
}
+
+ /* for package maintainers who don't use git: if version_static.txt exists in tt-rss root
+ 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) {
+ global $ttrss_version;
+
+ if (isset($ttrss_version))
+ return $ttrss_version;
+
+ $ttrss_version = "UNKNOWN (Unsupported)";
+
+ date_default_timezone_set('UTC');
+ $root_dir = dirname(dirname(__FILE__));
+
+ if (file_exists("$root_dir/version_static.txt")) {
+ $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)";
+ } else if (is_dir("$root_dir/.git")) {
+ $rc = 0;
+ $output = [];
+
+ exec("git log --pretty=".escapeshellarg('%ct %h')." -n1 HEAD " . escapeshellarg($root_dir) . ' 2>&1', $output, $rc);
+
+ if ($rc == 0) {
+ if (is_array($output) && count($output) > 0) {
+ list ($timestamp, $commit) = explode(" ", $output[0], 2);
+
+ $git_commit = $commit;
+ $git_timestamp = $timestamp;
+
+ $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit";
+ }
+ } else {
+ user_error("Unable to determine version: " . implode("\n", $output), E_USER_WARNING);
+ }
+ }
+
+ return $ttrss_version;
+ }