X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Fversion.php;h=751055b76fd13da1698e9f0193fd4bf32681f060;hb=75e765aa001c1dc3d4dc7686dc626e85b8af5cf1;hp=a6565a699072aacdb95881aec683e3704f49a249;hpb=ad031e4b6d1a6f6858b4714bb1f521a745344b4d;p=tt-rss.git diff --git a/include/version.php b/include/version.php index a6565a69..751055b7 100644 --- a/include/version.php +++ b/include/version.php @@ -1,3 +1,43 @@ + define('VERSION_STATIC', '18.8'); + + function get_version() { + date_default_timezone_set('UTC'); + $root_dir = dirname(dirname(__FILE__)); + + if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/HEAD")) { + $head = trim(file_get_contents("$root_dir/.git/HEAD")); + + if ($head) { + $matches = array(); + + if (preg_match("/^ref: (.*)/", $head, $matches)) { + $ref = $matches[1]; + + if (!file_exists("$root_dir/.git/$ref")) + return VERSION_STATIC; + $suffix = substr(trim(file_get_contents("$root_dir/.git/$ref")), 0, 7); + $timestamp = filemtime("$root_dir/.git/$ref"); + + define("GIT_VERSION_HEAD", $suffix); + define("GIT_VERSION_TIMESTAMP", $timestamp); + + return VERSION_STATIC . " ($suffix)"; + + } else { + $suffix = substr(trim($head), 0, 7); + $timestamp = filemtime("$root_dir/.git/HEAD"); + + define("GIT_VERSION_HEAD", $suffix); + define("GIT_VERSION_TIMESTAMP", $timestamp); + + return VERSION_STATIC . " ($suffix)"; + } + } + } + + return VERSION_STATIC; + + } + + define('VERSION', get_version());