2006-08-19 07:04:45 +00:00
|
|
|
<?php
|
2013-04-23 16:22:55 +00:00
|
|
|
|
2019-12-08 05:58:23 +00:00
|
|
|
/* 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 */
|
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
function get_version(&$git_commit = false, &$git_timestamp = false) {
|
|
|
|
$version = "UNKNOWN (Unsupported)";
|
|
|
|
|
2013-04-24 04:56:37 +00:00
|
|
|
date_default_timezone_set('UTC');
|
2013-04-23 16:22:55 +00:00
|
|
|
$root_dir = dirname(dirname(__FILE__));
|
|
|
|
|
2019-12-08 05:58:23 +00:00
|
|
|
if (file_exists("$root_dir/version_static.txt")) {
|
2019-12-09 04:11:34 +00:00
|
|
|
$version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)";
|
2019-12-08 05:58:23 +00:00
|
|
|
} else if (is_dir("$root_dir/.git")) {
|
2019-12-05 10:23:54 +00:00
|
|
|
$rc = 0;
|
|
|
|
$output = [];
|
2013-04-23 16:22:55 +00:00
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
exec("git log --pretty='%ct %h' -n1 HEAD " . escapeshellarg($root_dir), $output, $rc);
|
2016-03-23 16:08:38 +00:00
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
if ($rc == 0) {
|
|
|
|
if (is_array($output) && count($output) > 0) {
|
|
|
|
list ($timestamp, $commit) = explode(" ", $output[0], 2);
|
2016-03-23 16:08:38 +00:00
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
$git_commit = $commit;
|
|
|
|
$git_timestamp = $timestamp;
|
2016-03-23 16:08:38 +00:00
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
$version = strftime("%y.%m", $timestamp) . "-$commit";
|
2016-03-23 16:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-23 16:22:55 +00:00
|
|
|
}
|
2016-03-23 16:08:38 +00:00
|
|
|
|
2019-12-05 10:23:54 +00:00
|
|
|
return $version;
|
2013-04-23 16:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
define('VERSION', get_version());
|