public function givenRepositoryWithConfiguration() { $this->git = Repository::open($this->repository, '/usr/bin/git', 0755); $result = $this->git->transactional(function (TQ\Vcs\Repository\Transaction $t) { copy(realpath(dirname(__FILE__) . "/resources/{$this->configFileName}"), $this->repository . '/phploy.ini'); $t->setCommitMsg('Add configuration'); }); }
public function testRunWithoutConfigurationShouldReturnError() { $testHelper = new PHPLoyTestHelper('sftp', false); $git = Repository::open($testHelper->repository, '/usr/bin/git', 0755); $commit = $git->writeFile('test.txt', 'Test', 'Added test.txt'); $executionResult = $testHelper->whenRepositoryIsSynchronized(); $this->assertEquals(1, $executionResult); }
/** * Creates a new path information instance from a given URL * * @param string $url The URL * @param string $protocol The protocol registered * @param Binary $binary The Git binary */ public function __construct($url, $protocol, Binary $binary) { $url = self::parseUrl($url, $protocol); $this->fullPath = $url['path']; $this->repository = Repository::open($this->fullPath, $binary, false); $this->localPath = $this->repository->resolveLocalPath($this->fullPath); $this->ref = array_key_exists('fragment', $url) ? $url['fragment'] : 'HEAD'; $arguments = array(); if (array_key_exists('query', $url)) { parse_str($url['query'], $arguments); } $this->arguments = $arguments; $this->url = $protocol . '://' . $this->fullPath . '#' . $this->ref . '?' . http_build_query($this->arguments); }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ protected function setUp() { Helper::removeDirectory(TESTS_TMP_PATH); Helper::createDirectory(TESTS_TMP_PATH); $repositories = array(TESTS_REPO_PATH_1, TESTS_REPO_PATH_2, TESTS_REPO_PATH_3); foreach ($repositories as $n => $repository) { Helper::createDirectory($repository); Helper::initEmptyGitRepository($repository); for ($i = 0; $i < 5; $i++) { $file = sprintf('file_%d.txt', $i); $path = $repository . '/' . $file; file_put_contents($path, sprintf('Repository %d - File %d', $n + 1, $i + 1)); Helper::executeGit($repository, sprintf('add %s', escapeshellarg($file))); } Helper::executeGit($repository, sprintf('commit --message=%s', escapeshellarg('Initial commit'))); } clearstatcache(); $binary = new Binary(GIT_BINARY); StreamWrapper::register('git', $binary); StreamWrapper::getRepositoryRegistry()->addRepositories(array('repo1' => Repository::open(TESTS_REPO_PATH_1, $binary, false), 'repo2' => Repository::open(TESTS_REPO_PATH_2, $binary, false))); }
/** * * @return Repository */ protected function getRepository() { return Repository::open(TESTS_REPO_PATH_1, new Binary(GIT_BINARY)); }
/** * Get a Repository class for this environment. * * @return \TQ\Git\Repository\Repository */ public function getRepo() { return Repository::open($this->getSourcePath()); }
/** * 初始化git的关键变量 * * @param $project_id * * @return string */ protected function _initGitrepo($project_id) { App::import('Vendor', 'TQ', array('file' => 'TQ/Git/Repository/Repository.php')); $this->_gitInstance = \TQ\Git\Repository\Repository::open(Configure::read('GitSettings.repos_path') . DS . $project_id, Configure::read('GitSettings.bin_path')); }
/** * @param string $path * @param boolean|integer $create * @return Repository */ protected function getRepository($path, $create = false) { return Repository::open($path, new Binary(GIT_BINARY), $create); }
/** * Creates a new Repository instance for the given path * * @param string $path The path * @return RepositoryInterface */ protected function createRepositoryForPath($path) { return Repository::open($path, $this->git, false); }