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 updatesmaster
parent
6913158b82
commit
f30287be65
@ -1,43 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
define('VERSION_STATIC', '19.8');
|
|
||||||
|
|
||||||
function get_version() {
|
function get_version(&$git_commit = false, &$git_timestamp = false) {
|
||||||
|
$version = "UNKNOWN (Unsupported)";
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$root_dir = dirname(dirname(__FILE__));
|
$root_dir = dirname(dirname(__FILE__));
|
||||||
|
|
||||||
if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/HEAD")) {
|
if (is_dir("$root_dir/.git")) {
|
||||||
$head = trim(file_get_contents("$root_dir/.git/HEAD"));
|
$rc = 0;
|
||||||
|
$output = [];
|
||||||
if ($head) {
|
|
||||||
$matches = array();
|
|
||||||
|
|
||||||
if (preg_match("/^ref: (.*)/", $head, $matches)) {
|
|
||||||
$ref = $matches[1];
|
|
||||||
|
|
||||||
if (!file_exists("$root_dir/.git/$ref"))
|
exec("git log --pretty='%ct %h' -n1 HEAD " . escapeshellarg($root_dir), $output, $rc);
|
||||||
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);
|
if ($rc == 0) {
|
||||||
define("GIT_VERSION_TIMESTAMP", $timestamp);
|
if (is_array($output) && count($output) > 0) {
|
||||||
|
list ($timestamp, $commit) = explode(" ", $output[0], 2);
|
||||||
|
|
||||||
return VERSION_STATIC . " ($suffix)";
|
$git_commit = $commit;
|
||||||
|
$git_timestamp = $timestamp;
|
||||||
|
|
||||||
} else {
|
$version = strftime("%y.%m", $timestamp) . "-$commit";
|
||||||
$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;
|
return $version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
define('VERSION', get_version());
|
define('VERSION', get_version());
|
||||||
|
Loading…
Reference in New Issue