本文整理汇总了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);
}
}
示例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);
}
示例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());
}
}
示例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());
}
示例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('');
}
示例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));
}
示例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());
}
}
示例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);
}
示例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();
}
示例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());
}
}
示例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());
}
}
示例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);
}
示例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());
}
}
示例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);
}));
}
示例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());
}
}