executableFinder = $executableFinder; } public function locate(): string { $arguments = ProcessArgumentsCollection::forExecutable($this->executableFinder->find('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()); } }