Improve consistency and formatting of verbose output for update/install

main
Jordi Boggiano 12 years ago
parent 1aed88003f
commit 4d84f62cd9

@ -35,6 +35,7 @@ class InstallCommand extends Command
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

@ -35,6 +35,7 @@ class UpdateCommand extends Command
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

@ -14,6 +14,7 @@ namespace Composer\Downloader;
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 @@ class FileDownloader implements DownloaderInterface
$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 @@ class FileDownloader implements DownloaderInterface
*/
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.');
}

@ -234,9 +234,12 @@ class GitDownloader extends VcsDownloader
}
}
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());

@ -59,9 +59,12 @@ class HgDownloader extends VcsDownloader
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());

@ -79,9 +79,12 @@ class SvnDownloader extends VcsDownloader
}
}
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());

@ -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 @@ abstract class VcsDownloader implements DownloaderInterface
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 @@ abstract class VcsDownloader implements DownloaderInterface
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('');

@ -465,8 +465,9 @@ class Installer
}
}
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);

Loading…
Cancel
Save