/** * Execute an SVN command and try to fix up the process with credentials * if necessary. * * @param string $command The svn command to run. * @param string $url The SVN URL. * * @return string */ protected function execute($command, $url) { try { return $this->util->execute($command, $url); } catch (\RuntimeException $e) { throw new \RuntimeException('Repository ' . $this->url . ' could not be processed, ' . $e->getMessage()); } }
/** * Execute an SVN command and try to fix up the process with credentials * if necessary. * * @param string $baseUrl Base URL of the repository * @param string $command SVN command to run * @param string $url SVN url * @param string $cwd Working directory * @param string $path Target for a checkout * @throws \RuntimeException * @return string */ protected function execute($baseUrl, $command, $url, $cwd = null, $path = null) { $util = new SvnUtil($baseUrl, $this->io, $this->config); try { return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose()); } catch (\RuntimeException $e) { throw new \RuntimeException('Package could not be downloaded, ' . $e->getMessage()); } }
public function testCredentialsFromConfigWithCacheCredentialsFalse() { $url = 'http://svn.apache.org'; $config = new Config(); $config->merge(array('config' => array('http-basic' => array('svn.apache.org' => array('username' => 'foo', 'password' => 'bar'))))); $svn = new Svn($url, new NullIO(), $config); $svn->setCacheCredentials(false); $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); $this->assertEquals($this->getCmd(" --no-auth-cache --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); }
public function testInteractiveString() { $url = 'http://svn.example.org'; $svn = new Svn($url, new NullIO()); $this->assertEquals( "svn ls --non-interactive 'http://svn.example.org'", $svn->getCommand('svn ls', $url) ); }
/** * Execute an SVN command and try to fix up the process with credentials * if necessary. * * @param string $command The svn command to run. * @param string $url The SVN URL. * * @return string */ protected function execute($command, $url) { if (null === $this->util) { $this->util = new SvnUtil($this->baseUrl, $this->io, $this->process); } try { return $this->util->execute($command, $url); } catch (\RuntimeException $e) { throw new \RuntimeException('Repository ' . $this->url . ' could not be processed, ' . $e->getMessage()); } }
public function initialize() { $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/'); SvnUtil::cleanEnv(); if (isset($this->repoConfig['trunk-path'])) { $this->trunkPath = $this->repoConfig['trunk-path']; } if (isset($this->repoConfig['branches-path'])) { $this->branchesPath = $this->repoConfig['branches-path']; } if (isset($this->repoConfig['tags-path'])) { $this->tagsPath = $this->repoConfig['tags-path']; } if (array_key_exists('svn-cache-credentials', $this->repoConfig)) { $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials']; } if (isset($this->repoConfig['package-path'])) { $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/'); } if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) { $this->baseUrl = substr($this->url, 0, $pos); } $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->baseUrl)); $this->getBranches(); $this->getTags(); }
/** * Execute an SVN command and try to fix up the process with credentials * if necessary. * * @param string $command The svn command to run. * @param string $url The SVN URL. * * @return string */ protected function execute($command, $url) { if (null === $this->util) { $this->util = new SvnUtil($this->baseUrl, $this->io, $this->process); } try { return $this->util->execute($command, $url); } catch (\RuntimeException $e) { if (0 !== $this->process->execute('svn --version', $ignoredOutput)) { throw new \RuntimeException('Failed to load ' . $this->url . ', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()); } throw new \RuntimeException('Repository ' . $this->url . ' could not be processed, ' . $e->getMessage()); } }
/** * {@inheritDoc} */ public function doDownload(PackageInterface $package, $path, $url) { SvnUtil::cleanEnv(); $ref = $package->getSourceReference(); $repo = $package->getRepository(); if ($repo instanceof VcsRepository) { $repoConfig = $repo->getRepoConfig(); if (array_key_exists('svn-cache-credentials', $repoConfig)) { $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials']; } } $this->io->writeError(" Exporting " . $package->getSourceReference()); $this->execute($url, "svn export --force", sprintf("%s/%s", $url, $ref), null, $path); }
private function guessSvnVersion(array $config) { SvnUtil::cleanEnv(); // try to fetch current version from svn if (0 === $this->process->execute('svn info --xml', $output)) { $trunkPath = isset($config['trunk-path']) ? preg_quote($config['trunk-path'], '#') : 'trunk'; $branchesPath = isset($config['branches-path']) ? preg_quote($config['branches-path'], '#') : 'branches'; $tagsPath = isset($config['tags-path']) ? preg_quote($config['tags-path'], '#') : 'tags'; $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#'; if (preg_match($urlPattern, $output, $matches)) { if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) { // we are in a branches path $version = $this->versionParser->normalizeBranch($matches[3]); if ('9999999-dev' === $version) { $version = 'dev-' . $matches[3]; } return $version; } return $this->versionParser->normalize(trim($matches[1])); } } }