Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
vendor
/
wp-cli
/
vendor
/
composer
/
composer
/
src
/
Composer
/
Command
/
File Content:
StatusCommand.php
<?php /* * This file is part of Composer. * * (c) Nils Adermann <naderman@naderman.de> * Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Composer\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Composer\Downloader\ChangeReportInterface; use Composer\Downloader\DvcsDownloaderInterface; use Composer\Downloader\VcsCapableDownloaderInterface; use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Version\VersionGuesser; use Composer\Package\Version\VersionParser; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; use Composer\Script\ScriptEvents; use Composer\Util\ProcessExecutor; /** * @author Tiago Ribeiro <tiago.ribeiro@seegno.com> * @author Rui Marinho <rui.marinho@seegno.com> */ class StatusCommand extends BaseCommand { const EXIT_CODE_ERRORS = 1; const EXIT_CODE_UNPUSHED_CHANGES = 2; const EXIT_CODE_VERSION_CHANGES = 4; /** * @return void * @throws \Symfony\Component\Console\Exception\InvalidArgumentException */ protected function configure() { $this ->setName('status') ->setDescription('Shows a list of locally modified packages.') ->setDefinition(array( new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'), )) ->setHelp( <<<EOT The status command displays a list of dependencies that have been modified locally. Read more at https://getcomposer.org/doc/03-cli.md#status EOT ) ; } /** * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $composer = $this->getComposer(); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output); $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); // Dispatch pre-status-command $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true); $exitCode = $this->doExecute($input); // Dispatch post-status-command $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true); return $exitCode; } /** * @return int */ private function doExecute(InputInterface $input) { // init repos $composer = $this->getComposer(); $installedRepo = $composer->getRepositoryManager()->getLocalRepository(); $dm = $composer->getDownloadManager(); $im = $composer->getInstallationManager(); $errors = array(); $io = $this->getIO(); $unpushedChanges = array(); $vcsVersionChanges = array(); $parser = new VersionParser; $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser); $dumper = new ArrayDumper; // list packages foreach ($installedRepo->getCanonicalPackages() as $package) { $downloader = $dm->getDownloaderForPackage($package); $targetDir = $im->getInstallPath($package); if ($downloader instanceof ChangeReportInterface) { if (is_link($targetDir)) { $errors[$targetDir] = $targetDir . ' is a symbolic link.'; } if ($changes = $downloader->getLocalChanges($package, $targetDir)) { $errors[$targetDir] = $changes; } } if ($downloader instanceof VcsCapableDownloaderInterface) { if ($downloader->getVcsReference($package, $targetDir)) { switch ($package->getInstallationSource()) { case 'source': $previousRef = $package->getSourceReference(); break; case 'dist': $previousRef = $package->getDistReference(); break; default: $previousRef = null; } $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir); if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) { $vcsVersionChanges[$targetDir] = array( 'previous' => array( 'version' => $package->getPrettyVersion(), 'ref' => $previousRef, ), 'current' => array( 'version' => $currentVersion['pretty_version'], 'ref' => $currentVersion['commit'], ), ); } } } if ($downloader instanceof DvcsDownloaderInterface) { if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) { $unpushedChanges[$targetDir] = $unpushed; } } } // output errors/warnings if (!$errors && !$unpushedChanges && !$vcsVersionChanges) { $io->writeError('<info>No local changes</info>'); return 0; } if ($errors) { $io->writeError('<error>You have changes in the following dependencies:</error>'); foreach ($errors as $path => $changes) { if ($input->getOption('verbose')) { $indentedChanges = implode("\n", array_map(function ($line) { return ' ' . ltrim($line); }, explode("\n", $changes))); $io->write('<info>'.$path.'</info>:'); $io->write($indentedChanges); } else { $io->write($path); } } } if ($unpushedChanges) { $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>'); foreach ($unpushedChanges as $path => $changes) { if ($input->getOption('verbose')) { $indentedChanges = implode("\n", array_map(function ($line) { return ' ' . ltrim($line); }, explode("\n", $changes))); $io->write('<info>'.$path.'</info>:'); $io->write($indentedChanges); } else { $io->write($path); } } } if ($vcsVersionChanges) { $io->writeError('<warning>You have version variations in the following dependencies:</warning>'); foreach ($vcsVersionChanges as $path => $changes) { if ($input->getOption('verbose')) { // If we don't can't find a version, use the ref instead. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref']; $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref']; if ($io->isVeryVerbose()) { // Output the ref regardless of whether or not it's being used as the version $currentVersion .= sprintf(' (%s)', $changes['current']['ref']); $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']); } $io->write('<info>'.$path.'</info>:'); $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion)); } else { $io->write($path); } } } if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) { $io->writeError('Use --verbose (-v) to see a list of files'); } return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0); } }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
AboutCommand.php
1308 bytes
0644
ArchiveCommand.php
7815 bytes
0644
BaseCommand.php
10355 bytes
0644
BaseDependencyCommand.php
9100 bytes
0644
CheckPlatformReqsCommand.php
8009 bytes
0644
ClearCacheCommand.php
2296 bytes
0644
ConfigCommand.php
35185 bytes
0644
CreateProjectCommand.php
24747 bytes
0644
DependsCommand.php
1820 bytes
0644
DiagnoseCommand.php
28887 bytes
0644
DumpAutoloadCommand.php
5285 bytes
0644
ExecCommand.php
3539 bytes
0644
FundCommand.php
5412 bytes
0644
GlobalCommand.php
4007 bytes
0644
HomeCommand.php
5652 bytes
0644
InitCommand.php
45986 bytes
0644
InstallCommand.php
7733 bytes
0644
LicensesCommand.php
7415 bytes
0644
OutdatedCommand.php
5084 bytes
0644
ProhibitsCommand.php
2006 bytes
0644
ReinstallCommand.php
8552 bytes
0644
RemoveCommand.php
14381 bytes
0644
RequireCommand.php
22863 bytes
0644
RunScriptCommand.php
5223 bytes
0644
ScriptAliasCommand.php
2199 bytes
0644
SearchCommand.php
4799 bytes
0644
SelfUpdateCommand.php
26293 bytes
0644
ShowCommand.php
55499 bytes
0644
StatusCommand.php
8495 bytes
0644
SuggestsCommand.php
4081 bytes
0644
UpdateCommand.php
16773 bytes
0644
ValidateCommand.php
11564 bytes
0644
N4ST4R_ID | Naxtarrr