当前位置: 首页>>代码示例>>PHP>>正文


PHP PackageInterface::getSourceReference方法代码示例

本文整理汇总了PHP中Composer\Package\PackageInterface::getSourceReference方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface::getSourceReference方法的具体用法?PHP PackageInterface::getSourceReference怎么用?PHP PackageInterface::getSourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::getSourceReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doUpdate

 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);
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:25,代码来源:GitDownloader.php

示例2: doUpdate

 /**
  * {@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);
 }
开发者ID:richardmiller,项目名称:composer,代码行数:10,代码来源:HgDownloader.php

示例3: doUpdate

 /**
  * {@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());
     }
 }
开发者ID:dazzle-libraries,项目名称:composer,代码行数:32,代码来源:GitDownloader.php

示例4: formatVersion

 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());
 }
开发者ID:nicodmf,项目名称:composer,代码行数:7,代码来源:VersionParser.php

示例5: update

 /**
  * {@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('');
 }
开发者ID:aminembarki,项目名称:composer,代码行数:63,代码来源:VcsDownloader.php

示例6: doUpdate

 /**
  * {@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));
 }
开发者ID:richardmiller,项目名称:composer,代码行数:11,代码来源:SvnDownloader.php

示例7: doUpdate

 /**
  * {@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());
     }
 }
开发者ID:richardmiller,项目名称:composer,代码行数:13,代码来源:GitDownloader.php

示例8: doUpdate

 /**
  * {@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);
 }
开发者ID:nlegoff,项目名称:composer,代码行数:14,代码来源:GitDownloader.php

示例9: formatVersion

 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();
 }
开发者ID:rkallensee,项目名称:composer,代码行数:11,代码来源:VersionParser.php

示例10: doUpdate

 /**
  * {@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());
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:14,代码来源:HgDownloader.php

示例11: doUpdate

 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());
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:13,代码来源:HgDownloader.php

示例12: doDownload

 /**
  * {@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);
 }
开发者ID:linearsoft,项目名称:composer-svn-export,代码行数:17,代码来源:Downloader.php

示例13: doUpdate

 /**
  * {@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());
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:HgDownloader.php

示例14: getPackageFilename

 /**
  * 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);
     }));
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:22,代码来源:ArchiveManager.php

示例15: doUpdate

 /**
  * {@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());
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:18,代码来源:FossilDownloader.php


注:本文中的Composer\Package\PackageInterface::getSourceReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。