refactored

This commit is contained in:
n.pankin 2022-08-17 13:16:55 +03:00
parent 91aecc02f4
commit a589e20856
1 changed files with 6 additions and 9 deletions

View File

@ -10,16 +10,14 @@ task('version', function()
task('inc_game_version', function() task('inc_game_version', function()
{ {
global $GAME_ROOT; $path_to_version = get_path_to_version_file();
$path_to_version = $GAME_ROOT . get_version_file();
ensure_write($path_to_version, get_inc_game_version()); ensure_write($path_to_version, get_inc_game_version());
git_try_commit($path_to_version, "inc version"); git_try_commit($path_to_version, "inc version");
}); });
function game_version_full_str() function game_version_full_str()
{ {
global $GAME_ROOT; return trim(file(get_path_to_version_file())[0]);
return trim(file($GAME_ROOT . get_version_file())[0]);
} }
function game_version() function game_version()
@ -59,9 +57,10 @@ function game_patch_code()
return $code; return $code;
} }
function get_version_file() function get_path_to_version_file()
{ {
return '/' . getor('VERSION_FILE', "VERSION"); global $GAME_ROOT;
return $GAME_ROOT . '/' . getor('VERSION_FILE_NAME', "VERSION");
} }
function get_inc_game_version() function get_inc_game_version()
@ -93,9 +92,7 @@ function get_inc_game_version()
function get_version_file_lifetime() function get_version_file_lifetime()
{ {
global $GAME_ROOT; exec("git log --follow --format=%ad --date=format:'%Y-%m-%d %H:%M:%S' " . get_path_to_version_file() , $out, $ret);
exec("git log --follow --format=%ad --date=format:'%Y-%m-%d %H:%M:%S' " . $GAME_ROOT . get_version_file() , $out, $ret);
if($ret != 0) if($ret != 0)
throw new Exception("git error"); throw new Exception("git error");
$minutes = (time() - strtotime($out[0])) / 60; $minutes = (time() - strtotime($out[0])) / 60;