/** * @param GitWrapper $gitWrapper * @param GitCommand $gitCommand */ public function __construct(GitWrapper $gitWrapper, GitCommand $gitCommand) { $commandLine = ProcessUtils::escapeArgument($gitWrapper->getGitBinary()) . ' ' . $gitCommand->getCommandLine(); $directory = realpath($gitCommand->getDirectory()); $envVars = null; $wrapperEnvVars = $gitWrapper->getEnvVars(); if (!empty($wrapperEnvVars)) { $envVars = array_merge($_ENV, $_SERVER, $wrapperEnvVars); } parent::__construct($commandLine, $directory, $envVars, null, $gitCommand->getTimeout()); }
/** * @param GitRepository $gitRepository */ protected function changeRepository($gitRepository) { $repositoryDirectory = rtrim($gitRepository->getDirectory(), '/\\') . '/'; $fileName = uniqid('foo', true); touch($repositoryDirectory . $fileName); $this->gitWrapper->execute('add', [], [$fileName], $repositoryDirectory); $this->gitWrapper->execute('commit', ['m'], ['Add ' . $fileName], $repositoryDirectory); }
/** * @param array $settings * @return GitWrapper */ protected function getGitWrapper(array $settings) { $gitWrapper = new GitWrapper(); if (!empty($settings['git-binary'])) { $gitWrapper->setGitBinary($settings['git-binary']); } if (!empty($settings['env-vars'])) { $gitWrapper->setEnvVars($settings['env-vars']); } return $gitWrapper; }
public function testGetRepositoryReturnsInstance() { $directory = tempnam('git-wrapper', 'foo'); $repository = $this->gitWrapper->getRepository($directory); $this->assertInstanceOf(GitRepository::class, $repository); }