/** * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeLn(["<comment>Loading directories to pull for: {$this->directory->getPath()}</comment>", '']); if ($this->directory->getSubdirectories()->isEmpty()) { $output->writeln('<error>No subdirectories found.</error>'); return; } // Loop through all directories to search for repositories. foreach ($this->directory->getSubdirectories() as $subDirectory) { $quotedMatch = preg_quote(rtrim($input->getArgument('match'), DIRECTORY_SEPARATOR)); if ($input->getArgument('match') && !preg_match("/{$quotedMatch}/", $subDirectory)) { $output->writeln("<comment>Skipped {$subDirectory}</comment>"); continue; } // Instantiates package from directory. $package = new Package($subDirectory); $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag)); $stashed = false; // files not committed?! if (!$input->getOption('force') && !$input->getOption('stash') && $package->getCommitState()) { $output->writeln('<error>Local changes might be lost by pulling, commit/stash before continuing.</error>'); continue; } else { if ($input->getOption('stash') && $package->getCommitState()) { $package->stashChanges(); $stashed = true; } $package->pullLatestChanges(); if ($input->getOption('stash') && $stashed) { $package->restoreChanges(); } } // Return to original path. chdir($this->directory->getCurrentPath()); } }