Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SvnDownloader.php

function SvnDownloader::cleanChanges

@inheritDoc

Overrides VcsDownloader::cleanChanges

File

vendor/composer/composer/src/Composer/Downloader/SvnDownloader.php, line 132

Class

SvnDownloader
@author Ben Bieker <mail@ben-bieker.de> @author Till Klampaeckel <till@php.net>

Namespace

Composer\Downloader

Code

protected function cleanChanges(PackageInterface $package, string $path, bool $update) : PromiseInterface {
    if (null === ($changes = $this->getLocalChanges($package, $path))) {
        return \React\Promise\resolve(null);
    }
    if (!$this->io
        ->isInteractive()) {
        if (true === $this->config
            ->get('discard-changes')) {
            return $this->discardChanges($path);
        }
        return parent::cleanChanges($package, $path, $update);
    }
    $changes = array_map(static function ($elem) : string {
        return '    ' . $elem;
    }, Preg::split('{\\s*\\r?\\n\\s*}', $changes));
    $countChanges = count($changes);
    $this->io
        ->writeError(sprintf('    <error>' . $package->getPrettyName() . ' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
    $this->io
        ->writeError(array_slice($changes, 0, 10));
    if ($countChanges > 10) {
        $remainingChanges = $countChanges - 10;
        $this->io
            ->writeError(sprintf('    <info>' . $remainingChanges . ' more file%s modified, choose "v" to view the full list</info>', $remainingChanges === 1 ? '' : 's'));
    }
    while (true) {
        switch ($this->io
            ->ask('    <info>Discard changes [y,n,v,?]?</info> ', '?')) {
            case 'y':
                $this->discardChanges($path);
                break 2;
            case 'n':
                throw new \RuntimeException('Update aborted');
            case 'v':
                $this->io
                    ->writeError($changes);
                break;
            case '?':
            default:
                $this->io
                    ->writeError([
                    '    y - discard changes and apply the ' . ($update ? 'update' : 'uninstall'),
                    '    n - abort the ' . ($update ? 'update' : 'uninstall') . ' and let you manually clean things up',
                    '    v - view modified files',
                    '    ? - print help',
                ]);
                break;
        }
    }
    return \React\Promise\resolve(null);
}
RSS feed
Powered by Drupal