Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve consistency and formatting of verbose output for update/install

  • Loading branch information...
commit 4d84f62cd988eb6612872a37db13c437cf704702 1 parent 1aed880
@Seldaek Seldaek authored
View
1  src/Composer/Command/InstallCommand.php
@@ -35,6 +35,7 @@ protected function configure()
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
+ new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
))
->setHelp(<<<EOT
The <info>install</info> command reads the composer.json file from the
View
1  src/Composer/Command/UpdateCommand.php
@@ -35,6 +35,7 @@ protected function configure()
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
+ new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
))
->setHelp(<<<EOT
The <info>update</info> command reads the composer.json file from the
View
5 src/Composer/Downloader/FileDownloader.php
@@ -14,6 +14,7 @@
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
+use Composer\Package\Version\VersionParser;
use Composer\Util\Filesystem;
use Composer\Util\RemoteFilesystem;
@@ -64,7 +65,7 @@ public function download(PackageInterface $package, $path)
$fileName = $this->getFileName($package, $path);
- $this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
+ $this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$processUrl = $this->processUrl($url);
@@ -101,7 +102,7 @@ public function update(PackageInterface $initial, PackageInterface $target, $pat
*/
public function remove(PackageInterface $package, $path)
{
- $this->io->write(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
+ $this->io->write(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
}
View
7 src/Composer/Downloader/GitDownloader.php
@@ -234,9 +234,12 @@ protected function setPushUrl(PackageInterface $package, $path)
}
}
- protected function getCommitLogs($sourceReference, $targetReference, $path)
+ /**
+ * {@inheritDoc}
+ */
+ protected function getCommitLogs($fromReference, $toReference, $path)
{
- $command = sprintf('cd %s && git log %s..%s --pretty=format:"%%h - %%an: %%s"', escapeshellarg($path), $sourceReference, $targetReference);
+ $command = sprintf('cd %s && git log %s..%s --pretty=format:"%%h - %%an: %%s"', escapeshellarg($path), $fromReference, $toReference);
if (0 !== $this->process->execute($command, $output)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
View
7 src/Composer/Downloader/HgDownloader.php
@@ -59,9 +59,12 @@ public function getLocalChanges($path)
return trim($output) ?: null;
}
- protected function getCommitLogs($sourceReference, $targetReference, $path)
+ /**
+ * {@inheritDoc}
+ */
+ protected function getCommitLogs($fromReference, $toReference, $path)
{
- $command = sprintf('cd %s && hg log -r %s:%s --style compact', escapeshellarg($path), $sourceReference, $targetReference);
+ $command = sprintf('cd %s && hg log -r %s:%s --style compact', escapeshellarg($path), $fromReference, $toReference);
if (0 !== $this->process->execute($command, $output)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
View
7 src/Composer/Downloader/SvnDownloader.php
@@ -79,9 +79,12 @@ protected function execute($baseUrl, $command, $url, $cwd = null, $path = null)
}
}
- protected function getCommitLogs($sourceReference, $targetReference, $path)
+ /**
+ * {@inheritDoc}
+ */
+ protected function getCommitLogs($fromReference, $toReference, $path)
{
- $command = sprintf('cd %s && svn log -r%s:%s --incremental', escapeshellarg($path), $sourceReference, $targetReference);
+ $command = sprintf('cd %s && svn log -r%s:%s --incremental', escapeshellarg($path), $fromReference, $toReference);
if (0 !== $this->process->execute($command, $output)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
View
36 src/Composer/Downloader/VcsDownloader.php
@@ -13,6 +13,7 @@
namespace Composer\Downloader;
use Composer\Package\PackageInterface;
+use Composer\Package\Version\VersionParser;
use Composer\Util\ProcessExecutor;
use Composer\IO\IOInterface;
use Composer\Util\Filesystem;
@@ -50,7 +51,7 @@ public function download(PackageInterface $package, $path)
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
}
- $this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
+ $this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$this->filesystem->removeDirectory($path);
$this->doDownload($package, $path);
$this->io->write('');
@@ -65,23 +66,44 @@ public function update(PackageInterface $initial, PackageInterface $target, $pat
throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
}
+ $name = $target->getName();
if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
- $from = $initial->getSourceReference();
- $to = $target->getSourceReference();
+ if ($target->getSourceType() === 'svn') {
+ $from = $initial->getSourceReference();
+ $to = $target->getSourceReference();
+ } else {
+ $from = substr($initial->getSourceReference(), 0, 6);
+ $to = substr($target->getSourceReference(), 0, 6);
+ }
+ $name .= ' '.$initial->getPrettyVersion();
} else {
- $from = $initial->getPrettyVersion();
- $to = $target->getPrettyVersion();
+ $from = VersionParser::formatVersion($initial);
+ $to = VersionParser::formatVersion($target);
}
- $this->io->write(" - Updating <info>" . $target->getName() . "</info> from (<comment>" . $from . "</comment>) to (<comment>" . $to . "</comment>)");
+ $this->io->write(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
$this->enforceCleanDirectory($path);
$this->doUpdate($initial, $target, $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);
- $this->io->write($logs);
+
+ 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('');
View
5 src/Composer/Installer.php
@@ -465,8 +465,9 @@ protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = fa
}
}
- if ($this->verbose) {
- $this->io->write((string) $operation);
+ // output alias operations in verbose mode, or all ops in dry run
+ if ($this->dryRun || ($this->verbose && false !== strpos($operation->getJobType(), 'Alias'))) {
+ $this->io->write(' - ' . $operation);
}
$this->installationManager->execute($localRepo, $operation);
Please sign in to comment.
Something went wrong with that request. Please try again.