Show detailed changes in verbose mode, refs #842
parent
756c7a04fd
commit
209d3ebfc4
|
@ -29,8 +29,11 @@ class StatusCommand extends Command
|
||||||
$this
|
$this
|
||||||
->setName('status')
|
->setName('status')
|
||||||
->setDescription('Show a list of locally modified packages')
|
->setDescription('Show a list of locally modified packages')
|
||||||
|
->setDefinition(array(
|
||||||
|
new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
|
||||||
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
The status command displays a list of packages that have
|
The status command displays a list of dependencies that have
|
||||||
been modified locally.
|
been modified locally.
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
@ -56,8 +59,8 @@ EOT
|
||||||
if ($downloader instanceof VcsDownloader) {
|
if ($downloader instanceof VcsDownloader) {
|
||||||
$targetDir = $im->getInstallPath($package);
|
$targetDir = $im->getInstallPath($package);
|
||||||
|
|
||||||
if ($downloader->hasLocalChanges($targetDir)) {
|
if ($changes = $downloader->getLocalChanges($targetDir)) {
|
||||||
$errors[] = $targetDir;
|
$errors[$targetDir] = $changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,11 +69,23 @@ EOT
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
$output->writeln('<info>No local changes</info>');
|
$output->writeln('<info>No local changes</info>');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<error>You have changes in the following packages:</error>');
|
$output->writeln('<error>You have changes in the following dependencies:</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $path => $changes) {
|
||||||
$output->writeln($error);
|
if ($input->getOption('verbose')) {
|
||||||
|
$indentedChanges = implode("\n", array_map(function ($line) {
|
||||||
|
return ' ' . $line;
|
||||||
|
}, explode("\n", $changes)));
|
||||||
|
$output->writeln('<info>'.$path.'</info>:');
|
||||||
|
$output->writeln($indentedChanges);
|
||||||
|
} else {
|
||||||
|
$output->writeln($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($errors && !$input->getOption('verbose')) {
|
||||||
|
$output->writeln('Use --verbose (-v) to see modified files');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors ? 1 : 0;
|
return $errors ? 1 : 0;
|
||||||
|
|
|
@ -66,14 +66,14 @@ class GitDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function hasLocalChanges($path)
|
public function getLocalChanges($path)
|
||||||
{
|
{
|
||||||
$command = sprintf('cd %s && git status --porcelain --untracked-files=no', escapeshellarg($path));
|
$command = sprintf('cd %s && git status --porcelain --untracked-files=no', escapeshellarg($path));
|
||||||
if (0 !== $this->process->execute($command, $output)) {
|
if (0 !== $this->process->execute($command, $output)) {
|
||||||
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) trim($output);
|
return trim($output) ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateToCommit($path, $reference, $branch, $date)
|
protected function updateToCommit($path, $reference, $branch, $date)
|
||||||
|
|
|
@ -52,10 +52,10 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function hasLocalChanges($path)
|
public function getLocalChanges($path)
|
||||||
{
|
{
|
||||||
$this->process->execute(sprintf('cd %s && hg st', escapeshellarg($path)), $output);
|
$this->process->execute(sprintf('cd %s && hg st', escapeshellarg($path)), $output);
|
||||||
|
|
||||||
return (bool) trim($output);
|
return trim($output) ?: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,11 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function hasLocalChanges($path)
|
public function getLocalChanges($path)
|
||||||
{
|
{
|
||||||
$this->process->execute('svn status --ignore-externals', $output, $path);
|
$this->process->execute('svn status --ignore-externals', $output, $path);
|
||||||
|
|
||||||
return preg_match('{^ *[^X ] +}m', $output);
|
return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -90,7 +90,7 @@ abstract class VcsDownloader implements DownloaderInterface
|
||||||
*/
|
*/
|
||||||
protected function enforceCleanDirectory($path)
|
protected function enforceCleanDirectory($path)
|
||||||
{
|
{
|
||||||
if ($this->hasLocalChanges($path)) {
|
if (null !== $this->getLocalChanges($path)) {
|
||||||
throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
|
throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ abstract class VcsDownloader implements DownloaderInterface
|
||||||
* Checks for changes to the local copy
|
* Checks for changes to the local copy
|
||||||
*
|
*
|
||||||
* @param string $path package directory
|
* @param string $path package directory
|
||||||
* @return boolean whether package has local changes
|
* @return string|null changes or null
|
||||||
*/
|
*/
|
||||||
abstract public function hasLocalChanges($path);
|
abstract public function getLocalChanges($path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue