1
0
Fork 0

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 changed
pull/8444/head
Nils Adermann 2019-11-23 12:31:33 +01:00
parent 88b051c96b
commit a732ea5dd8
11 changed files with 43 additions and 18 deletions

View File

@ -61,7 +61,7 @@ class InstallOperation extends SolverOperation
*/
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().')';
}
/**

View File

@ -62,7 +62,7 @@ class MarkAliasInstalledOperation extends SolverOperation
*/
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().')';
}
/**

View File

@ -62,7 +62,7 @@ class MarkAliasUninstalledOperation extends SolverOperation
*/
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().')';
}
/**

View File

@ -48,9 +48,4 @@ abstract class SolverOperation implements OperationInterface
* @return string
*/
abstract public function show($lock);
protected function formatVersion(PackageInterface $package)
{
return $package->getFullPrettyVersion();
}
}

View File

@ -61,7 +61,7 @@ class UninstallOperation extends SolverOperation
*/
public function show($lock)
{
return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->package->getFullPrettyVersion().')';
}
/**

View File

@ -74,7 +74,18 @@ class UpdateOperation extends SolverOperation
*/
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.')';
}
/**

View File

@ -210,18 +210,30 @@ abstract class BasePackage implements PackageInterface
/**
* {@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();
}
// if source reference is a sha1 hash -- truncate
if ($truncate && strlen($this->getSourceReference()) === 40) {
return $this->getPrettyVersion() . ' ' . substr($this->getSourceReference(), 0, 7);
switch ($displayMode) {
case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
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()

View File

@ -21,6 +21,10 @@ use Composer\Repository\RepositoryInterface;
*/
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
*
@ -198,9 +202,10 @@ interface PackageInterface
* @see getPrettyVersion
*
* @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
*/
public function getFullPrettyVersion($truncate = true);
public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
/**
* Returns the release date of the package

View File

@ -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
--EXPECT--
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)
Updating g/g (dev-master 0000000 => dev-master 1111111)

View File

@ -28,3 +28,4 @@ Updating a dev package forcing it's reference should not do anything if the refe
--RUN--
update
--EXPECT--
Updating a/a (dev-master def000 => dev-master )

View File

@ -62,4 +62,4 @@ update mirrors
"platform-dev": []
}
--EXPECT--
Updating a/a (1.0.0 old-hg-ref => 1.0.0 new-git-ref)