예제 #1
0
 /**
  * @param RepositoryList $repositories
  * @description
  * проверить измененные файлы в директории
  * если есть измененные - проверяем название ветки
  * берем название проектной ветки
  * собираем вендоры для которых нужно создать ветки
  * если ветки есть - запрашиваем подтверждение
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     $branch = $repositories->getProjectModel()->getBranch();
     $vendorsWithoutBranch = $this->findVendorsWithoutBranch($repositories->getVendorModels(), $branch);
     $this->createBranches($branch, $vendorsWithoutBranch);
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }
예제 #2
0
 /**
  * @param RepositoryList $repositories
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     $parallelProcess = new ParallelProcess($this->getSymfonyStyle());
     /** @var RepositoryModel[] $list */
     $list = $repositories->getVendorModels();
     $model = null;
     foreach ($list as $model) {
         $parallelProcess->add($model->getProvider()->buildCommand('fetch', []), $model->getAbsolutePath(), $this->isDryRun(), false);
     }
     $parallelProcess->run();
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }
예제 #3
0
 /**
  * @param RepositoryList $repositories
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     $parallelProcess = new ParallelProcess($this->getSymfonyStyle());
     $remoteBranch = null;
     if ($this->getInput()->hasArgument('remote-branch')) {
         $remoteBranch = $this->getInput()->getArgument('remote-branch');
     }
     /** @var RepositoryModel[] $list */
     $list = $repositories->getVendorModels();
     $progressBar = new ProgressBarHelper($this->getSymfonyStyle());
     $progressBar->create(count($list));
     $model = null;
     foreach ($list as $model) {
         $progressBar->advance('Fetch status of ' . ($model->getPath() ?: 'project repository'));
         $currentBranch = $model->getBranch();
         $hasCommits = $model->hasCommits();
         $needPull = false;
         if ($currentBranch !== $remoteBranch || 'master' !== $currentBranch && 'master' !== $remoteBranch || $hasCommits) {
             $needPull = true;
         }
         if ($needPull) {
             $parallelProcess->add($model->getProvider()->buildCommand('fetch', []), $model->getAbsolutePath(), $this->isDryRun(), false);
             if ($model->getProvider()->hasRemoteBranch($currentBranch)) {
                 $parallelProcess->add($model->getProvider()->buildCommand('pull', ['origin', $currentBranch]), $model->getAbsolutePath(), $this->isDryRun(), false);
             }
             $needMerge = !empty($remoteBranch) && $remoteBranch != $currentBranch;
             if ($needMerge && $model->getProvider()->hasRemoteBranch($remoteBranch)) {
                 $parallelProcess->add($model->getProvider()->buildCommand('pull', ['origin', $remoteBranch]), $model->getAbsolutePath(), $this->isDryRun(), false);
             }
             if ($needMerge && !$model->hasConflicts() && $model->getProvider()->hasLocalBranch($remoteBranch)) {
                 $parallelProcess->add($model->getProvider()->buildCommand('merge', [$remoteBranch]), $model->getAbsolutePath(), $this->isDryRun(), true);
             }
         } else {
             $this->getLogger()->debug('Skipped', [$model->getPackageName(), 'current' => $currentBranch, 'remote' => $remoteBranch, 'hasCommits' => $hasCommits]);
         }
     }
     $progressBar->finish();
     $parallelProcess->run();
     foreach ($list as $model) {
         if ($model->hasConflicts()) {
             $this->getSymfonyStyle()->writeln($model->getPackageName());
             $this->getSymfonyStyle()->writeln($model->getConflicts());
         }
     }
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }
예제 #4
0
 /**
  * @param RepositoryList $repositories
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     /** @var RepositoryModel[] $list */
     $list = $repositories->getVendorModels();
     foreach ($list as $model) {
         if ($model->hasCommits() || !$model->hasRemote()) {
             $branch = $model->getBranch();
             if ($model->hasRemote()) {
                 $model->getProvider()->run('pull', ['origin', $branch], $this->isDryRun(), true);
             }
             $model->getProvider()->run('push', ['origin', $branch], $this->isDryRun(), true);
             $this->getSymfonyStyle()->writeln(sprintf('%s pushed to %s', $model->getPath(), $branch));
         } else {
             $this->getLogger()->debug('Nothing to push', ['name' => $model->getPath()]);
         }
     }
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }
예제 #5
0
 /**
  * @param RepositoryList $repositories
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     $model = $repositories->getProjectModel();
     if ($model->hasConflicts()) {
         if (false !== stripos($model->getConflicts(), ComposerHelper::COMPOSER_JSON)) {
             $this->getSymfonyStyle()->error('You should resolve composer.json conflict first');
             $this->stopPropagation();
             return;
         }
     }
     $composerFilename = $repositories->getProjectModel()->getAbsolutePath() . DIRECTORY_SEPARATOR . 'composer.json';
     $helper = new ComposerHelper();
     $composerData = $helper->jsonDecode(file_get_contents($composerFilename));
     $data = $repositories->getVendorModels();
     $vendorsModels = [];
     foreach ($data as $model) {
         $vendorsModels[strtolower($model->getPackageName())] = $model;
     }
     $projectBranch = $repositories->getProjectModel()->getBranch();
     $updateFlag = false;
     if (!empty($composerData['require'])) {
         $changes = $this->changeVersion($composerData['require'], $vendorsModels, $projectBranch);
         $composerData['require'] = array_merge($composerData['require'], $changes);
         $updateFlag = $updateFlag || !empty($changes);
     }
     if (!empty($composerData['require-dev'])) {
         $changes = $this->changeVersion($composerData['require-dev'], $vendorsModels, $projectBranch);
         $composerData['require-dev'] = array_merge($composerData['require-dev'], $changes);
         $updateFlag = $updateFlag || !empty($changes);
     }
     if (!$this->isDryRun()) {
         $jsonEncodedData = json_encode($composerData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         file_put_contents($composerFilename, $jsonEncodedData);
     }
     if ($updateFlag) {
         $this->getSymfonyStyle()->success('File composer.json updated');
     }
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }
예제 #6
0
 /**
  * @param RepositoryList $repositories
  * @return string
  */
 public function execute(RepositoryList $repositories)
 {
     $this->getLogger()->debug('Run plugin', [get_called_class()]);
     $comment = $this->getInput()->getOption('message');
     $branch = $repositories->getProjectModel()->getBranch();
     $comment = CommentHelper::buildComment($comment, $branch);
     $vendors = $repositories->getVendorModels();
     $this->getSymfonyStyle()->newLine();
     $progressBar = new ProgressBarHelper($this->getSymfonyStyle());
     $progressBar->create(count($vendors));
     foreach ($vendors as $model) {
         $progressBar->advance($model->getPath());
         if ($model->hasChanges()) {
             if ($model->hasConflicts()) {
                 $progressBar->finish();
                 $this->getSymfonyStyle()->newLine();
                 $this->getSymfonyStyle()->error('Conflicts detected');
                 $this->getSymfonyStyle()->writeln($model->getPath());
                 $this->getSymfonyStyle()->writeln($model->getConflicts());
                 $this->getSymfonyStyle()->newLine();
                 $this->stopPropagation();
                 break;
             }
             $model->getProvider()->run('add', ['.'], $this->isDryRun());
             $params = [];
             if ($this->getInput()->hasOption('no-verify') && $this->getInput()->getOption('no-verify')) {
                 $params[] = '--no-verify';
             }
             $params[] = '-m';
             $params[] = $comment;
             $this->getSymfonyStyle()->newLine();
             $model->getProvider()->run('commit', $params, $this->isDryRun(), true);
             $this->getSymfonyStyle()->writeln(sprintf('%s: commit changes to (%s)', $model->getPath(), $model->getBranch()));
         } else {
             $this->getLogger()->debug('Changes not found', ['commit vendor']);
         }
     }
     $progressBar->finish();
     $this->getLogger()->debug('End plugin', [get_called_class()]);
 }