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
This commit is contained in:
parent
6913158b82
commit
f30287be65
|
@ -590,15 +590,20 @@ class RPC extends Handler_Protected {
|
||||||
function checkforupdates() {
|
function checkforupdates() {
|
||||||
$rv = [];
|
$rv = [];
|
||||||
|
|
||||||
if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && defined("GIT_VERSION_TIMESTAMP")) {
|
$git_timestamp = false;
|
||||||
|
$git_commit = false;
|
||||||
|
|
||||||
|
get_version($git_commit, $git_timestamp);
|
||||||
|
|
||||||
|
if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) {
|
||||||
$content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]);
|
$content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]);
|
||||||
|
|
||||||
if ($content) {
|
if ($content) {
|
||||||
$content = json_decode($content, true);
|
$content = json_decode($content, true);
|
||||||
|
|
||||||
if ($content && isset($content["changeset"])) {
|
if ($content && isset($content["changeset"])) {
|
||||||
if ((int)GIT_VERSION_TIMESTAMP < (int)$content["changeset"]["timestamp"] &&
|
if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
|
||||||
GIT_VERSION_HEAD != $content["changeset"]["id"]) {
|
$git_commit != $content["changeset"]["id"]) {
|
||||||
|
|
||||||
$rv = $content["changeset"];
|
$rv = $content["changeset"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,7 +560,6 @@
|
||||||
session_regenerate_id(true);
|
session_regenerate_id(true);
|
||||||
|
|
||||||
$_SESSION["uid"] = $user_id;
|
$_SESSION["uid"] = $user_id;
|
||||||
$_SESSION["version"] = VERSION_STATIC;
|
|
||||||
$_SESSION["auth_module"] = $auth_module;
|
$_SESSION["auth_module"] = $auth_module;
|
||||||
|
|
||||||
$pdo = DB::pdo();
|
$pdo = DB::pdo();
|
||||||
|
|
|
@ -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) {
|
exec("git log --pretty='%ct %h' -n1 HEAD " . escapeshellarg($root_dir), $output, $rc);
|
||||||
$matches = array();
|
|
||||||
|
|
||||||
if (preg_match("/^ref: (.*)/", $head, $matches)) {
|
if ($rc == 0) {
|
||||||
$ref = $matches[1];
|
if (is_array($output) && count($output) > 0) {
|
||||||
|
list ($timestamp, $commit) = explode(" ", $output[0], 2);
|
||||||
|
|
||||||
if (!file_exists("$root_dir/.git/$ref"))
|
$git_commit = $commit;
|
||||||
return VERSION_STATIC;
|
$git_timestamp = $timestamp;
|
||||||
$suffix = substr(trim(file_get_contents("$root_dir/.git/$ref")), 0, 7);
|
|
||||||
$timestamp = filemtime("$root_dir/.git/$ref");
|
|
||||||
|
|
||||||
define("GIT_VERSION_HEAD", $suffix);
|
$version = strftime("%y.%m", $timestamp) . "-$commit";
|
||||||
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;
|
return $version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
define('VERSION', get_version());
|
define('VERSION', get_version());
|
||||||
|
|
Loading…
Reference in New Issue