PocketMine-MP
5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
Git.php
1
<?php
2
3
/*
4
*
5
* ____ _ _ __ __ _ __ __ ____
6
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* @author PocketMine Team
17
* @link http://www.pocketmine.net/
18
*
19
*
20
*/
21
22
declare(strict_types=1);
23
24
namespace
pocketmine\utils
;
25
26
use
function
str_repeat;
27
use
function
strlen;
28
use
function
trim;
29
30
final
class
Git
{
31
32
private
function
__construct(){
33
//NOOP
34
}
35
41
public
static
function
getRepositoryState
(
string
$dir,
bool
&$dirty) : ?string{
42
if(
Process
::execute(
"git -C \"$dir\" rev-parse HEAD"
, $out) === 0 && $out !== false && strlen($out = trim($out)) === 40){
43
if
(
Process::execute
(
"git -C \"$dir\" diff --quiet"
) === 1 ||
Process::execute
(
"git -C \"$dir\" diff --cached --quiet"
) === 1){
//Locally-modified
44
$dirty =
true
;
45
}
46
return
$out;
47
}
48
return
null
;
49
}
50
55
public
static
function
getRepositoryStatePretty
(
string
$dir) : string{
56
$dirty = false;
57
$detectedHash = self::getRepositoryState($dir, $dirty);
58
if
($detectedHash !==
null
){
59
return
$detectedHash . ($dirty ?
"-dirty"
:
""
);
60
}
61
return
str_repeat(
"00"
, 20);
62
}
63
}
pocketmine\utils\Git
Definition
Git.php:30
pocketmine\utils\Git\getRepositoryStatePretty
static getRepositoryStatePretty(string $dir)
Definition
Git.php:55
pocketmine\utils\Git\getRepositoryState
static getRepositoryState(string $dir, bool &$dirty)
Definition
Git.php:41
pocketmine\utils\Process
Definition
Process.php:45
pocketmine\utils\Process\execute
static execute(string $command, ?string &$stdout=null, ?string &$stderr=null)
Definition
Process.php:163
pocketmine\utils
Definition
AssumptionFailedError.php:24
src
utils
Git.php
Generated by
1.12.0