%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/public_html/admin1/vendor/phpro/grumphp/src/Locator/ |
Upload File : |
<?php
declare(strict_types=1);
namespace GrumPHP\Locator;
use GrumPHP\Collection\ProcessArgumentsCollection;
use GrumPHP\Exception\RuntimeException;
use GrumPHP\Process\ProcessFactory;
use Symfony\Component\Process\ExecutableFinder;
class GitWorkingDirLocator
{
/**
* @var ExecutableFinder
*/
private $executableFinder;
public function __construct(ExecutableFinder $executableFinder)
{
$this->executableFinder = $executableFinder;
}
public function locate(): string
{
$arguments = ProcessArgumentsCollection::forExecutable((string) $this->executableFinder->find('git', 'git'));
$arguments->add('rev-parse');
$arguments->add('--show-toplevel');
$process = ProcessFactory::fromArguments($arguments);
$process->run();
if (!$process->isSuccessful()) {
throw new RuntimeException(
'The git directory could not be found. Did you initialize git? ('.$process->getErrorOutput().')'
);
}
return trim($process->getOutput());
}
}