mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Remove VERSION and GIT_COMMIT constants
these are now lazily computed in VersionInfo as needed.
This commit is contained in:
@ -23,6 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\utils\Git;
|
||||
use pocketmine\utils\VersionString;
|
||||
use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "4.0.0";
|
||||
@ -32,4 +36,37 @@ final class VersionInfo{
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/** @var string|null */
|
||||
private static $gitHash = null;
|
||||
|
||||
public static function getGitHash() : string{
|
||||
if(self::$gitHash === null){
|
||||
$gitHash = str_repeat("00", 20);
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
$gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
|
||||
}else{
|
||||
$phar = new \Phar(\Phar::running(false));
|
||||
$meta = $phar->getMetadata();
|
||||
if(isset($meta["git"])){
|
||||
$gitHash = $meta["git"];
|
||||
}
|
||||
}
|
||||
|
||||
self::$gitHash = $gitHash;
|
||||
}
|
||||
|
||||
return self::$gitHash;
|
||||
}
|
||||
|
||||
/** @var VersionString|null */
|
||||
private static $fullVersion = null;
|
||||
|
||||
public static function getVersionObj() : VersionString{
|
||||
if(self::$fullVersion === null){
|
||||
self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER);
|
||||
}
|
||||
return self::$fullVersion;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user