Exemple #1
0
 /**
  * {@inheritDoc}
  */
 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();
 }
 /**
  * {@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);
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     SvnUtil::cleanEnv();
     $ref = $target->getSourceReference();
     if (!is_dir($path . '/.svn')) {
         throw new \RuntimeException('The .svn directory is missing from ' . $path . ', see http://getcomposer.org/commit-deps for more information');
     }
     $flags = "";
     if (0 === $this->process->execute('svn --version', $output)) {
         if (preg_match('{(\\d+(?:\\.\\d+)+)}', $output, $match) && version_compare($match[1], '1.7.0', '>=')) {
             $flags .= ' --ignore-ancestry';
         }
     }
     $this->io->writeError("    Checking out " . $ref);
     $this->execute($url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $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]));
         }
     }
 }