diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 0b2aa9cbd..f04b6ceee 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine { + use pocketmine\utils\Git; use pocketmine\utils\MainLogger; use pocketmine\utils\ServerKiller; use pocketmine\utils\Terminal; @@ -186,13 +187,7 @@ namespace pocketmine { $gitHash = str_repeat("00", 20); if(\Phar::running(true) === ""){ - $gitPath = \pocketmine\PATH; - if(Utils::execute("git -C \"$gitPath\" rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){ - $gitHash = trim($out); - if(Utils::execute("git -C \"$gitPath\" diff --quiet") === 1 or Utils::execute("git -C \"$gitPath\" diff --cached --quiet") === 1){ //Locally-modified - $gitHash .= "-dirty"; - } - } + $gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH); }else{ $phar = new \Phar(\Phar::running(false)); $meta = $phar->getMetadata(); diff --git a/src/pocketmine/utils/Git.php b/src/pocketmine/utils/Git.php new file mode 100644 index 000000000..549ea97b0 --- /dev/null +++ b/src/pocketmine/utils/Git.php @@ -0,0 +1,70 @@ +