Make some assumptions about proc_open()

This commit is contained in:
Dylan K. Taylor 2025-01-06 23:05:06 +00:00
parent 1b2d2a3fe1
commit db9ba83001
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 12 additions and 3 deletions

View File

@ -39,7 +39,7 @@ final class Git{
* @param bool $dirty reference parameter, set to whether the repo has local changes
*/
public static function getRepositoryState(string $dir, bool &$dirty) : ?string{
if(Process::execute("git -C \"$dir\" rev-parse HEAD", $out) === 0 && $out !== false && strlen($out = trim($out)) === 40){
if(Process::execute("git -C \"$dir\" rev-parse HEAD", $out) === 0 && strlen($out = trim($out)) === 40){
if(Process::execute("git -C \"$dir\" diff --quiet") === 1 || Process::execute("git -C \"$dir\" diff --cached --quiet") === 1){ //Locally-modified
$dirty = true;
}

View File

@ -174,8 +174,17 @@ final class Process{
return -1;
}
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
$out = stream_get_contents($pipes[1]);
if($out === false){
throw new AssumptionFailedError("Presume this can't happen for proc_open ... ???");
}
$stdout = $out;
$err = stream_get_contents($pipes[2]);
if($err === false){
throw new AssumptionFailedError("Presume this can't happen for proc_open ... ???");
}
$stderr = $err;
foreach($pipes as $p){
fclose($p);