Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 protected function cleanChanges($path, $update)
 {
     if (!$this->io->isInteractive()) {
         return parent::cleanChanges($path, $update);
     }
     if (!($changes = $this->getLocalChanges($path))) {
         return;
     }
     $changes = array_map(function ($elem) {
         return '    ' . $elem;
     }, preg_split('{\\s*\\r?\\n\\s*}', $changes));
     $this->io->write('    <error>The package has modified files:</error>');
     $this->io->write(array_slice($changes, 0, 10));
     if (count($changes) > 10) {
         $this->io->write('    <info>' . count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
     }
     while (true) {
         switch ($this->io->ask('    <info>Discard changes [y,n,v,?]?</info> ', '?')) {
             case 'y':
                 if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
                     throw new \RuntimeException("Could not reset changes\n\n:" . $this->process->getErrorOutput());
                 }
                 break 2;
             case 'n':
                 throw new \RuntimeException('Update aborted');
             case 'v':
                 $this->io->write($changes);
                 break;
             case '?':
             default:
                 $this->io->write(array('    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;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 protected function cleanChanges(PackageInterface $package, $path, $update)
 {
     GitUtil::cleanEnv();
     $path = $this->normalizePath($path);
     $unpushed = $this->getUnpushedChanges($package, $path);
     if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
         throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: ' . "\n" . $unpushed);
     }
     if (!($changes = $this->getLocalChanges($package, $path))) {
         return;
     }
     if (!$this->io->isInteractive()) {
         $discardChanges = $this->config->get('discard-changes');
         if (true === $discardChanges) {
             return $this->discardChanges($path);
         }
         if ('stash' === $discardChanges) {
             if (!$update) {
                 return parent::cleanChanges($package, $path, $update);
             }
             return $this->stashChanges($path);
         }
         return parent::cleanChanges($package, $path, $update);
     }
     $changes = array_map(function ($elem) {
         return '    ' . $elem;
     }, preg_split('{\\s*\\r?\\n\\s*}', $changes));
     $this->io->writeError('    <error>The package has modified files:</error>');
     $this->io->writeError(array_slice($changes, 0, 10));
     if (count($changes) > 10) {
         $this->io->writeError('    <info>' . count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
     }
     while (true) {
         switch ($this->io->ask('    <info>Discard changes [y,n,v,d,' . ($update ? 's,' : '') . '?]?</info> ', '?')) {
             case 'y':
                 $this->discardChanges($path);
                 break 2;
             case 's':
                 if (!$update) {
                     goto help;
                 }
                 $this->stashChanges($path);
                 break 2;
             case 'n':
                 throw new \RuntimeException('Update aborted');
             case 'v':
                 $this->io->writeError($changes);
                 break;
             case 'd':
                 $this->viewDiff($path);
                 break;
             case '?':
             default:
                 help:
                 $this->io->writeError(array('    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', '    d - view local modifications (diff)'));
                 if ($update) {
                     $this->io->writeError('    s - stash changes and try to reapply them after the update');
                 }
                 $this->io->writeError('    ? - print help');
                 break;
         }
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 protected function cleanChanges($path, $update)
 {
     if (!($changes = $this->getLocalChanges($path))) {
         return;
     }
     if (!$this->io->isInteractive()) {
         $discardChanges = $this->config->get('discard-changes');
         if (true === $discardChanges) {
             return $this->discardChanges($path);
         }
         if ('stash' === $discardChanges) {
             if (!$update) {
                 return parent::cleanChanges($path, $update);
             }
             return $this->stashChanges($path);
         }
         return parent::cleanChanges($path, $update);
     }
     $changes = array_map(function ($elem) {
         return '    ' . $elem;
     }, preg_split('{\\s*\\r?\\n\\s*}', $changes));
     $this->io->write('    <error>The package has modified files:</error>');
     $this->io->write(array_slice($changes, 0, 10));
     if (count($changes) > 10) {
         $this->io->write('    <info>' . count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
     }
     while (true) {
         switch ($this->io->ask('    <info>Discard changes [y,n,v,' . ($update ? 's,' : '') . '?]?</info> ', '?')) {
             case 'y':
                 $this->discardChanges($path);
                 break 2;
             case 's':
                 if (!$update) {
                     goto help;
                 }
                 $this->stashChanges($path);
                 break 2;
             case 'n':
                 throw new \RuntimeException('Update aborted');
             case 'v':
                 $this->io->write($changes);
                 break;
             case '?':
             default:
                 help:
                 $this->io->write(array('    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'));
                 if ($update) {
                     $this->io->write('    s - stash changes and try to reapply them after the update');
                 }
                 $this->io->write('    ? - print help');
                 break;
         }
     }
 }