1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-15 23:15:57 +00:00
Files
tt-rss/include/version.php
Andrew Dolgov f30287be65 versioning changes
- remove VERSION_STATIC - https://community.tt-rss.org/t/versioning-changes-for-trunk/2974
- report git commit/timestamp properly by invoking git instead of trying to parse .git/HEAD etc
- remove git-related global constants used when checking for updates
2019-12-05 13:23:54 +03:00

31 lines
682 B
PHP

<?php
function get_version(&$git_commit = false, &$git_timestamp = false) {
$version = "UNKNOWN (Unsupported)";
date_default_timezone_set('UTC');
$root_dir = dirname(dirname(__FILE__));
if (is_dir("$root_dir/.git")) {
$rc = 0;
$output = [];
exec("git log --pretty='%ct %h' -n1 HEAD " . escapeshellarg($root_dir), $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;
$version = strftime("%y.%m", $timestamp) . "-$commit";
}
}
}
return $version;
}
define('VERSION', get_version());