예제 #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);
     }
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = escapeshellarg($target->getSourceReference());
     $path = escapeshellarg($path);
     $this->io->write("    Updating to " . $target->getSourceReference());
     $this->process->execute(sprintf('cd %s && hg pull && hg up %s', $path, $ref), $ignoredOutput);
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = escapeshellarg($target->getSourceReference());
     $path = escapeshellarg($path);
     $this->io->write("    Checking out " . $target->getSourceReference());
     $this->process->execute(sprintf('cd %s && git fetch && git checkout %2$s && git reset --hard %2$s', $path, $ref), $ignoredOutput);
 }
예제 #4
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');
     }
     $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());
     }
 }
예제 #5
0
 public static function formatVersion(PackageInterface $package, $truncate = true)
 {
     if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
         return $package->getPrettyVersion();
     }
     return $package->getPrettyVersion() . ' ' . ($truncate ? substr($package->getSourceReference(), 0, 6) : $package->getSourceReference());
 }
예제 #6
0
 /**
  * {@inheritDoc}
  */
 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $name = $target->getName();
     if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
         if ($target->getSourceType() === 'svn') {
             $from = $initial->getSourceReference();
             $to = $target->getSourceReference();
         } else {
             $from = substr($initial->getSourceReference(), 0, 7);
             $to = substr($target->getSourceReference(), 0, 7);
         }
         $name .= ' ' . $initial->getPrettyVersion();
     } else {
         $from = VersionParser::formatVersion($initial);
         $to = VersionParser::formatVersion($target);
     }
     $this->io->write("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
     $this->cleanChanges($initial, $path, true);
     $urls = $target->getSourceUrls();
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 $url = realpath($url);
             }
             $this->doUpdate($initial, $target, $path, $url);
             break;
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->write('Failed: [' . get_class($e) . '] ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->write('    Failed, trying the next URL');
             } else {
                 // in case of failed update, try to reapply the changes before aborting
                 $this->reapplyChanges($path);
                 throw $e;
             }
         }
     }
     $this->reapplyChanges($path);
     // print the commit logs if in verbose mode
     if ($this->io->isVerbose()) {
         $message = 'Pulling in changes:';
         $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
         if (!trim($logs)) {
             $message = 'Rolling back changes:';
             $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
         }
         if (trim($logs)) {
             $logs = implode("\n", array_map(function ($line) {
                 return '      ' . $line;
             }, explode("\n", $logs)));
             $this->io->write('    ' . $message);
             $this->io->write($logs);
         }
     }
     $this->io->write('');
 }
예제 #7
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = escapeshellarg($target->getSourceReference());
     $path = escapeshellarg($path);
     $url = escapeshellarg($target->getSourceUrl());
     $this->io->write("    Checking out " . $target->getSourceReference());
     $this->process->execute(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref));
 }
예제 #8
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = escapeshellarg($target->getSourceReference());
     $path = escapeshellarg($path);
     $this->io->write("    Checking out " . $target->getSourceReference());
     $command = sprintf('cd %s && git fetch && git checkout %2$s && git reset --hard %2$s', $path, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput)) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
예제 #9
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $target->getSourceReference());
     $command = 'cd %s && git remote set-url origin %s && git fetch origin && git fetch --tags origin && git checkout %3$s && git reset --hard %3$s';
     $commandCallable = function ($url) use($ref, $path, $command) {
         return sprintf($command, escapeshellarg($path), escapeshellarg($url), escapeshellarg($ref));
     };
     $this->runCommand($commandCallable, $target->getSourceUrl());
     $this->setPushUrl($target, $path);
 }
예제 #10
0
 public static function formatVersion(PackageInterface $package, $truncate = true)
 {
     if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
         return $package->getPrettyVersion();
     }
     // if source reference is a sha1 hash -- truncate
     if ($truncate && strlen($package->getSourceReference()) === 40) {
         return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 7);
     }
     return $package->getPrettyVersion() . ' ' . $package->getSourceReference();
 }
예제 #11
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $url = escapeshellarg($target->getSourceUrl());
     $ref = escapeshellarg($target->getSourceReference());
     $path = escapeshellarg($path);
     $this->io->write("    Updating to " . $target->getSourceReference());
     $command = sprintf('cd %s && hg pull %s && hg up %s', $path, $url, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput)) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
예제 #12
0
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $url = escapeshellarg($target->getSourceUrl());
     $ref = escapeshellarg($target->getSourceReference());
     $this->io->write("    Updating to " . $target->getSourceReference());
     if (!is_dir($path . '/.hg')) {
         throw new \RuntimeException('The .hg directory is missing from ' . $path . ', see http://getcomposer.org/commit-deps for more information');
     }
     $command = sprintf('hg pull %s && hg up %s', $url, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
예제 #13
0
 /**
  * {@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);
 }
예제 #14
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     $this->checkSecureHttp($url);
     $url = ProcessExecutor::escape($url);
     $ref = ProcessExecutor::escape($target->getSourceReference());
     $this->io->writeError("    Updating to " . $target->getSourceReference());
     if (!$this->hasMetadataRepository($path)) {
         throw new \RuntimeException('The .hg directory is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
     }
     $command = sprintf('hg pull %s && hg up %s', $url, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
예제 #15
0
 /**
  * Generate a distinct filename for a particular version of a package.
  *
  * @param PackageInterface $package The package to get a name for
  *
  * @return string A filename without an extension
  */
 public function getPackageFilename(PackageInterface $package)
 {
     $nameParts = array(preg_replace('#[^a-z0-9-_.]#i', '-', $package->getName()));
     if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
         $nameParts = array_merge($nameParts, array($package->getDistReference(), $package->getDistType()));
     } else {
         $nameParts = array_merge($nameParts, array($package->getPrettyVersion(), $package->getDistReference()));
     }
     if ($package->getSourceReference()) {
         $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
     }
     return implode('-', array_filter($nameParts, function ($p) {
         return !empty($p);
     }));
 }
예제 #16
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     // Ensure we are allowed to use this URL by config
     $this->config->prohibitUrlByConfig($url, $this->io);
     $url = ProcessExecutor::escape($url);
     $ref = ProcessExecutor::escape($target->getSourceReference());
     $this->io->writeError("    Updating to " . $target->getSourceReference());
     if (!$this->hasMetadataRepository($path)) {
         throw new \RuntimeException('The .fslckout file is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
     }
     $command = sprintf('fossil pull && fossil up %s', $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
예제 #17
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $url = $target->getSourceUrl();
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $ref);
     $this->execute($url, "svn switch", sprintf("%s/%s", $url, $ref), $path);
 }
예제 #18
0
 /**
  * Try to determine the build number from a composer package
  *
  * @param \Composer\Package\PackageInterface $package
  *
  * @return string
  */
 public static function determineBuildNumberFromPackage(PackageInterface $package)
 {
     if ($package->isDev()) {
         $buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
         if (is_null($buildNumber)) {
             $buildNumber = substr($package->getSourceReference(), 0, 8);
         }
     } else {
         $installedVersion = $package->getPrettyVersion();
         // SemVer supports build numbers, but fall back to just using
         // version number if not available; at time of writing, composer
         // did not support SemVer 2.0.0 build numbers fully:
         // @see https://github.com/composer/composer/issues/2422
         $plusPos = strpos($installedVersion, '+');
         if ($plusPos !== false) {
             $buildNumber = substr($installedVersion, $plusPos + 1);
         } else {
             $buildNumber = self::determineBuildNumberFromBrowscapBuildFile();
             if (is_null($buildNumber)) {
                 $buildNumber = $installedVersion;
             }
         }
     }
     return $buildNumber;
 }
예제 #19
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $target->getSourceReference());
     $command = 'cd %s && git remote set-url composer %s && git fetch composer && git fetch --tags composer && git checkout %3$s && git reset --hard %3$s';
     // capture username/password from github URL if there is one
     $this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output);
     if (preg_match('{^composer\\s+https://(.+):(.+)@github.com/}im', $output, $match)) {
         $this->io->setAuthorization('github.com', $match[1], $match[2]);
     }
     // TODO: BC for the composer remote that didn't exist, to be remove after May 18th.
     $this->process->execute(sprintf('cd %s && git remote add composer %s', escapeshellarg($path), escapeshellarg($initial->getSourceUrl())), $ignoredOutput);
     $commandCallable = function ($url) use($ref, $path, $command) {
         return sprintf($command, escapeshellarg($path), escapeshellarg($url), escapeshellarg($ref));
     };
     $this->runCommand($commandCallable, $target->getSourceUrl());
 }
예제 #20
0
 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $name = $target->getName();
     if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
         if ($target->getSourceType() === 'svn') {
             $from = $initial->getSourceReference();
             $to = $target->getSourceReference();
         } else {
             $from = substr($initial->getSourceReference(), 0, 7);
             $to = substr($target->getSourceReference(), 0, 7);
         }
         $name .= ' ' . $initial->getPrettyVersion();
     } else {
         $from = VersionParser::formatVersion($initial);
         $to = VersionParser::formatVersion($target);
     }
     $this->io->write("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
     $this->cleanChanges($initial, $path, true);
     try {
         $this->doUpdate($initial, $target, $path);
     } catch (\Exception $e) {
         $this->reapplyChanges($path);
         throw $e;
     }
     $this->reapplyChanges($path);
     if ($this->io->isVerbose()) {
         $message = 'Pulling in changes:';
         $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
         if (!trim($logs)) {
             $message = 'Rolling back changes:';
             $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
         }
         if (trim($logs)) {
             $logs = implode("\n", array_map(function ($line) {
                 return '      ' . $line;
             }, explode("\n", $logs)));
             $this->io->write('    ' . $message);
             $this->io->write($logs);
         }
     }
     $this->io->write('');
 }
예제 #21
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $url = $target->getSourceUrl();
     $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');
     }
     $this->io->write("    Checking out " . $ref);
     $this->execute($url, "svn switch", sprintf("%s/%s", $url, $ref), $path);
 }
예제 #22
0
 /**
  * {@inheritDoc}
  */
 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $this->io->write("  - Package <info>" . $target->getName() . "</info> (<comment>" . $target->getPrettyVersion() . "</comment>)");
     $this->enforceCleanDirectory($path);
     $this->doUpdate($initial, $target, $path);
     $this->io->write('');
 }
예제 #23
0
 public function dump(PackageInterface $package)
 {
     $keys = array('binaries' => 'bin', 'type', 'extra', 'installationSource' => 'installation-source', 'autoload', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path');
     $data = array();
     $data['name'] = $package->getPrettyName();
     $data['version'] = $package->getPrettyVersion();
     $data['version_normalized'] = $package->getVersion();
     if ($package->getTargetDir()) {
         $data['target-dir'] = $package->getTargetDir();
     }
     if ($package->getSourceType()) {
         $data['source']['type'] = $package->getSourceType();
         $data['source']['url'] = $package->getSourceUrl();
         $data['source']['reference'] = $package->getSourceReference();
     }
     if ($package->getDistType()) {
         $data['dist']['type'] = $package->getDistType();
         $data['dist']['url'] = $package->getDistUrl();
         $data['dist']['reference'] = $package->getDistReference();
         $data['dist']['shasum'] = $package->getDistSha1Checksum();
     }
     if ($package->getArchiveExcludes()) {
         $data['archive']['exclude'] = $package->getArchiveExcludes();
     }
     foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
         if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
             foreach ($links as $link) {
                 $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
             }
             ksort($data[$type]);
         }
     }
     if ($packages = $package->getSuggests()) {
         ksort($packages);
         $data['suggest'] = $packages;
     }
     if ($package->getReleaseDate()) {
         $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
     }
     $data = $this->dumpValues($package, $keys, $data);
     if ($package instanceof CompletePackageInterface) {
         $keys = array('scripts', 'license', 'authors', 'description', 'homepage', 'keywords', 'repositories', 'support');
         $data = $this->dumpValues($package, $keys, $data);
         if (isset($data['keywords']) && is_array($data['keywords'])) {
             sort($data['keywords']);
         }
     }
     if ($package instanceof RootPackageInterface) {
         $minimumStability = $package->getMinimumStability();
         if ($minimumStability) {
             $data['minimum-stability'] = $minimumStability;
         }
     }
     return $data;
 }
예제 #24
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);
     }
 }
예제 #25
0
 /**
  * Convert a package version into string representation.
  *
  * @param PackageInterface $package       The package to extract the version from.
  *
  * @param bool             $fullReference Flag if the complete reference shall be added or an abbreviated form.
  *
  * @return string
  *
  * @throws \RuntimeException If the package is a dev package and does not have valid reference information.
  */
 public static function convertPackageVersion(PackageInterface $package, $fullReference = false)
 {
     $version = $package->getPrettyVersion();
     if ('dev' === $package->getStability()) {
         if (null === ($reference = $package->getDistReference())) {
             if (null === ($reference = $package->getSourceReference())) {
                 throw new \RuntimeException('Unable to determine reference for ' . $package->getPrettyName());
             }
         }
         $version .= '#' . (!$fullReference ? substr($reference, 0, 8) : $reference);
     }
     return $version;
 }
예제 #26
0
 public function doDownload(PackageInterface $package, $path)
 {
     $ref = $package->getSourceReference();
     $label = $package->getPrettyVersion();
     $this->io->write('    Cloning ' . $ref);
     $this->initPerforce($package, $path);
     $this->perforce->setStream($ref);
     $this->perforce->p4Login($this->io);
     $this->perforce->writeP4ClientSpec();
     $this->perforce->connectClient();
     $this->perforce->syncCodeBase($label);
     $this->perforce->cleanupClientSpec();
 }
예제 #27
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);
 }
예제 #28
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $ref);
     $command = 'cd %s && git remote set-url composer %s && git fetch composer && git fetch --tags composer';
     // capture username/password from github URL if there is one
     $this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output);
     if (preg_match('{^composer\\s+https://(.+):(.+)@github.com/}im', $output, $match)) {
         $this->io->setAuthorization('github.com', $match[1], $match[2]);
     }
     $commandCallable = function ($url) use($ref, $path, $command) {
         return sprintf($command, escapeshellarg($path), escapeshellarg($url), escapeshellarg($ref));
     };
     $this->runCommand($commandCallable, $target->getSourceUrl());
     $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate());
 }
예제 #29
0
 public function dump(PackageInterface $package)
 {
     $keys = array('binaries' => 'bin', 'scripts', 'type', 'extra', 'installationSource' => 'installation-source', 'license', 'authors', 'description', 'homepage', 'keywords', 'autoload', 'repositories', 'includePaths' => 'include-path', 'support');
     $data = array();
     $data['name'] = $package->getPrettyName();
     $data['version'] = $package->getPrettyVersion();
     $data['version_normalized'] = $package->getVersion();
     if ($package->getTargetDir()) {
         $data['target-dir'] = $package->getTargetDir();
     }
     if ($package->getReleaseDate()) {
         $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
     }
     if ($package->getSourceType()) {
         $data['source']['type'] = $package->getSourceType();
         $data['source']['url'] = $package->getSourceUrl();
         $data['source']['reference'] = $package->getSourceReference();
     }
     if ($package->getDistType()) {
         $data['dist']['type'] = $package->getDistType();
         $data['dist']['url'] = $package->getDistUrl();
         $data['dist']['reference'] = $package->getDistReference();
         $data['dist']['shasum'] = $package->getDistSha1Checksum();
     }
     foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
         if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
             foreach ($links as $link) {
                 $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
             }
         }
     }
     if ($packages = $package->getSuggests()) {
         $data['suggest'] = $packages;
     }
     foreach ($keys as $method => $key) {
         if (is_numeric($method)) {
             $method = $key;
         }
         $getter = 'get' . ucfirst($method);
         $value = $package->{$getter}();
         if (null !== $value && !(is_array($value) && 0 === count($value))) {
             $data[$key] = $value;
         }
     }
     return $data;
 }
예제 #30
0
 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
 {
     $ref = $target->getSourceReference();
     $this->io->write("    Checking out " . $ref);
     $command = 'cd %s && git remote set-url composer %s && git fetch composer && git fetch --tags composer';
     // capture username/password from URL if there is one
     $this->process->execute(sprintf('cd %s && git remote -v', escapeshellarg($path)), $output);
     if (preg_match('{^(?:composer|origin)\\s+https?://(.+):(.+)@([^/]+)}im', $output, $match)) {
         $this->io->setAuthentication($match[3], urldecode($match[1]), urldecode($match[2]));
     }
     // added in git 1.7.1, prevents prompting the user
     putenv('GIT_ASKPASS=echo');
     $commandCallable = function ($url) use($ref, $path, $command) {
         return sprintf($command, escapeshellarg($path), escapeshellarg($url), escapeshellarg($ref));
     };
     $this->runCommand($commandCallable, $target->getSourceUrl());
     $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate());
 }