Display source/dist refs if updates do not change the version
We now output an update when only a source or dist ref changes even if it's a stable version so in these cases the output needs to contain the ref to make it clear to users what changedpull/8444/head
parent
88b051c96b
commit
a732ea5dd8
|
@ -61,7 +61,7 @@ class InstallOperation extends SolverOperation
|
||||||
*/
|
*/
|
||||||
public function show($lock)
|
public function show($lock)
|
||||||
{
|
{
|
||||||
return ($lock ? 'Locking ' : 'Installing ').$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
|
return ($lock ? 'Locking ' : 'Installing ').$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,7 @@ class MarkAliasInstalledOperation extends SolverOperation
|
||||||
*/
|
*/
|
||||||
public function show($lock)
|
public function show($lock)
|
||||||
{
|
{
|
||||||
return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
|
return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getFullPrettyVersion().')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,7 @@ class MarkAliasUninstalledOperation extends SolverOperation
|
||||||
*/
|
*/
|
||||||
public function show($lock)
|
public function show($lock)
|
||||||
{
|
{
|
||||||
return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
|
return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getFullPrettyVersion().')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,9 +48,4 @@ abstract class SolverOperation implements OperationInterface
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract public function show($lock);
|
abstract public function show($lock);
|
||||||
|
|
||||||
protected function formatVersion(PackageInterface $package)
|
|
||||||
{
|
|
||||||
return $package->getFullPrettyVersion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class UninstallOperation extends SolverOperation
|
||||||
*/
|
*/
|
||||||
public function show($lock)
|
public function show($lock)
|
||||||
{
|
{
|
||||||
return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
|
return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -74,7 +74,18 @@ class UpdateOperation extends SolverOperation
|
||||||
*/
|
*/
|
||||||
public function show($lock)
|
public function show($lock)
|
||||||
{
|
{
|
||||||
return 'Updating '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).' => '.$this->formatVersion($this->targetPackage).')';
|
$fromVersion = $this->initialPackage->getFullPrettyVersion();
|
||||||
|
$toVersion = $this->targetPackage->getFullPrettyVersion();
|
||||||
|
|
||||||
|
if ($fromVersion === $toVersion && $this->initialPackage->getSourceReference() !== $this->targetPackage->getSourceReference()) {
|
||||||
|
$fromVersion = $this->initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
|
||||||
|
$toVersion = $this->targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
|
||||||
|
} elseif ($fromVersion === $toVersion && $this->initialPackage->getDistReference() !== $this->targetPackage->getDistReference()) {
|
||||||
|
$fromVersion = $this->initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
|
||||||
|
$toVersion = $this->targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Updating '.$this->initialPackage->getPrettyName().' ('.$fromVersion.' => '.$toVersion.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -210,18 +210,30 @@ abstract class BasePackage implements PackageInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function getFullPrettyVersion($truncate = true)
|
public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
|
||||||
{
|
{
|
||||||
if (!$this->isDev() || !in_array($this->getSourceType(), array('hg', 'git'))) {
|
if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
|
||||||
|
(!$this->isDev() || !in_array($this->getSourceType(), array('hg', 'git')))
|
||||||
|
) {
|
||||||
return $this->getPrettyVersion();
|
return $this->getPrettyVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if source reference is a sha1 hash -- truncate
|
switch ($displayMode) {
|
||||||
if ($truncate && strlen($this->getSourceReference()) === 40) {
|
case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
|
||||||
return $this->getPrettyVersion() . ' ' . substr($this->getSourceReference(), 0, 7);
|
case PackageInterface::DISPLAY_SOURCE_REF:
|
||||||
|
$reference = $this->getSourceReference();
|
||||||
|
break;
|
||||||
|
case PackageInterface::DISPLAY_DIST_REF:
|
||||||
|
$reference = $this->getDistReference();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPrettyVersion() . ' ' . $this->getSourceReference();
|
// if source reference is a sha1 hash -- truncate
|
||||||
|
if ($truncate && strlen($reference) === 40) {
|
||||||
|
return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getPrettyVersion() . ' ' . $reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStabilityPriority()
|
public function getStabilityPriority()
|
||||||
|
|
|
@ -21,6 +21,10 @@ use Composer\Repository\RepositoryInterface;
|
||||||
*/
|
*/
|
||||||
interface PackageInterface
|
interface PackageInterface
|
||||||
{
|
{
|
||||||
|
const DISPLAY_SOURCE_REF_IF_DEV = 0;
|
||||||
|
const DISPLAY_SOURCE_REF = 1;
|
||||||
|
const DISPLAY_DIST_REF = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the package's name without version info, thus not a unique identifier
|
* Returns the package's name without version info, thus not a unique identifier
|
||||||
*
|
*
|
||||||
|
@ -198,9 +202,10 @@ interface PackageInterface
|
||||||
* @see getPrettyVersion
|
* @see getPrettyVersion
|
||||||
*
|
*
|
||||||
* @param bool $truncate If the source reference is a sha1 hash, truncate it
|
* @param bool $truncate If the source reference is a sha1 hash, truncate it
|
||||||
|
* @param int $displayMode One of the DISPLAY_ constants on this interface determining display of references
|
||||||
* @return string version
|
* @return string version
|
||||||
*/
|
*/
|
||||||
public function getFullPrettyVersion($truncate = true);
|
public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the release date of the package
|
* Returns the release date of the package
|
||||||
|
|
|
@ -215,5 +215,6 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an
|
||||||
update a/a b/b d/d g/g
|
update a/a b/b d/d g/g
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Updating a/a (dev-master 1111111 => dev-master 2222222)
|
Updating a/a (dev-master 1111111 => dev-master 2222222)
|
||||||
|
Updating b/b (2.0.3 1111111 => 2.0.3 2222222)
|
||||||
Installing e/e (dev-master 1111111)
|
Installing e/e (dev-master 1111111)
|
||||||
Updating g/g (dev-master 0000000 => dev-master 1111111)
|
Updating g/g (dev-master 0000000 => dev-master 1111111)
|
||||||
|
|
|
@ -28,3 +28,4 @@ Updating a dev package forcing it's reference should not do anything if the refe
|
||||||
--RUN--
|
--RUN--
|
||||||
update
|
update
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Updating a/a (dev-master def000 => dev-master )
|
||||||
|
|
|
@ -62,4 +62,4 @@ update mirrors
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Updating a/a (1.0.0 old-hg-ref => 1.0.0 new-git-ref)
|
||||||
|
|
Loading…
Reference in New Issue