Esempio n. 1
0
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $this->cleanEnv();
     $path = $this->normalizePath($path);
     if (!is_dir($path . '/.git')) {
         throw new \RuntimeException('The .git directory is missing from ' . $path . ', see http://getcomposer.org/commit-deps for more information');
     }
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $ref);
     $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
     $this->process->execute('git remote -v', $output, $path);
     if (preg_match('{^(?:composer|origin)\\s+https?://(.+):(.+)@([^/]+)}im', $output, $match)) {
         $this->io->setAuthentication($match[3], urldecode($match[1]), urldecode($match[2]));
     }
     $commandCallable = function ($url) use($command) {
         return sprintf($command, escapeshellarg($url));
     };
     $this->runCommand($commandCallable, $target->getSourceUrl(), $path);
     if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
         if ($target->getDistReference() === $target->getSourceReference()) {
             $target->setDistReference($newRef);
         }
         $target->setSourceReference($newRef);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     GitUtil::cleanEnv();
     if (!$this->hasMetadataRepository($path)) {
         throw new \RuntimeException('The .git directory is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
     }
     $updateOriginUrl = false;
     if (0 === $this->process->execute('git remote -v', $output, $path) && preg_match('{^origin\\s+(?P<url>\\S+)}m', $output, $originMatch) && preg_match('{^composer\\s+(?P<url>\\S+)}m', $output, $composerMatch)) {
         if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
             $updateOriginUrl = true;
         }
     }
     $ref = $target->getSourceReference();
     $this->io->writeError("    Checking out " . $ref);
     $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
     $commandCallable = function ($url) use($command) {
         return sprintf($command, ProcessExecutor::escape($url));
     };
     $this->gitUtil->runCommand($commandCallable, $url, $path);
     if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
         if ($target->getDistReference() === $target->getSourceReference()) {
             $target->setDistReference($newRef);
         }
         $target->setSourceReference($newRef);
     }
     if ($updateOriginUrl) {
         $this->updateOriginUrl($path, $target->getSourceUrl());
     }
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     GitUtil::cleanEnv();
     if (!$this->hasMetadataRepository($path)) {
         throw new \RuntimeException('The .git directory is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
     }
     $ref = $target->getSourceReference();
     $this->io->writeError("    Checking out " . $ref);
     $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
     $commandCallable = function ($url) use($command) {
         return sprintf($command, ProcessExecutor::escape($url));
     };
     $this->gitUtil->runCommand($commandCallable, $url, $path);
     if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
         if ($target->getDistReference() === $target->getSourceReference()) {
             $target->setDistReference($newRef);
         }
         $target->setSourceReference($newRef);
     }
 }
Esempio n. 4
0
 private function updateInstallReferences(PackageInterface $package, $reference)
 {
     if (!$reference) {
         return;
     }
     $package->setSourceReference($reference);
     $package->setDistReference($reference);
     if (preg_match('{^https?://(?:(?:www\\.)?bitbucket\\.org|(api\\.)?github\\.com)/}i', $package->getDistUrl())) {
         $package->setDistUrl(preg_replace('{(?<=/)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl()));
     }
 }
Esempio n. 5
0
 public function setDistReference($reference)
 {
     return $this->aliasOf->setDistReference($reference);
 }