X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=include%2Fversion.php;h=e5f91bd9cf9ce0411a7561debab14ab9593a6c6f;hb=ac68939d7ecb012fc998f9e6a12bf8b09aadf214;hp=44d7cf53da30225e8e5f31cdd579525817be25d8;hpb=e8133ac1cb618545c55b8405faef5f43a5feb636;p=tt-rss.git diff --git a/include/version.php b/include/version.php index 44d7cf53..e5f91bd9 100644 --- a/include/version.php +++ b/include/version.php @@ -1,3 +1,43 @@ + define('VERSION_STATIC', '18.12'); + + 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());