public function executeActions(Repository $repository, InputInterface $input, OutputInterface $output, array &$synchronizedPaths = array())
 {
     $this->environment->setRepository($repository);
     $path = $this->environment->getPlaceholderReplacer()->replace($this->environment->getConfiguration()->getStoragePath() . DIRECTORY_SEPARATOR . $this->environment->getConfiguration()->getDirectoryScheme(), $this->environment);
     $this->environment->setPath($path);
     switch ($repository->getType()) {
         case Repository::TYPE_GIT:
             $vcs = new GitRepository($path);
             if ($input->getOption('sync')) {
                 $sync = new SyncCommand();
                 $sync->setEnvironment($this->environment);
                 $sync->sync($repository, $input, $output, $synchronizedPaths);
                 $this->environment->setRepository($repository);
                 $this->environment->setPath($path);
             }
             if (!$vcs->isInitialized()) {
                 throw new NotSynchronizedRepository(sprintf('The repository %s/%s is not synchronized', $repository->getOwner(), $repository->getName()));
             }
             $vcs->checkout()->force()->execute($repository->getRealRef());
             break;
         default:
             // TODO
             throw new \Exception('Incomplete implementation');
     }
     $action = $this->environment->getConfiguration()->getAction();
     if (!$action) {
         throw new IncompleteConfigurationException('No actions configured');
     }
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
         $output->writeln(sprintf(' * <info>ccabs:repositories:execute</info> run action on repository <comment>%s</comment>', $path));
     }
     $this->environment->setVcs($vcs);
     $action->run($this->environment);
     $this->environment->setVcs(null);
     $this->environment->setPath(null);
     $this->environment->setRepository(null);
 }
 /**
  * Execute the command.
  *
  * @return mixed Depend on the command.
  * @throws GitException
  */
 protected function run()
 {
     $process = $this->processBuilder->getProcess();
     if ($this->output !== null) {
         throw new GitException('Command cannot be executed twice', $process->getWorkingDirectory(), $process->getCommandLine(), $this->output, '');
     }
     $this->repository->getConfig()->getLogger()->debug(sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()));
     if ($this->dryRun) {
         return $process->getCommandLine();
     }
     $process->run();
     $this->output = $process->getOutput();
     $this->output = rtrim($this->output, "\r\n");
     if (!$process->isSuccessful()) {
         throw GitException::createFromProcess('Could not execute git command', $process);
     }
     return $this->output;
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $exitCode = 0;
     $git = new GitRepository($this->input->getArgument('git-dir'));
     $branches = $git->branch()->listBranches()->getNames();
     $composer = json_decode(file_get_contents($input->getArgument('git-dir') . '/composer.json'), true);
     if (!isset($composer['extra']['branch-alias'])) {
         if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->writeln('<info>No branch aliases found, skipping test.</info>');
         }
         return 0;
     }
     foreach ($composer['extra']['branch-alias'] as $branch => $alias) {
         $simpleBranch = $this->simplifyBranch($branch);
         if (!in_array($simpleBranch, $branches)) {
             if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
                 $output->writeln(sprintf('<info>Skipping non existing branch %s(%s)</info>', $branch, $alias));
             }
             continue;
         }
         $tag = $this->getTagFromBranch($simpleBranch);
         // No tag yet, therefore definately before any version.
         if ($tag === null) {
             $output->writeln(sprintf('<comment>Branch alias %s(%s) has not been tagged yet.</comment>', $branch, $alias));
         } elseif (!$this->validate($tag, $alias)) {
             $output->writeln(sprintf('<error>The branch alias %s(%s) is behind the latest branch tag %s!</error>', $branch, $alias, $tag));
             $exitCode = 1;
         } else {
             if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
                 $output->writeln(sprintf('<info>Branch alias %s(%s) is ahead of the latest branch tag.</info>', $branch, $alias));
             }
         }
     }
     return $exitCode;
 }
 /**
  * Retrieve the data of the current user on the system.
  *
  * @param GitRepository $git The repository to extract all files from.
  *
  * @return string
  *
  * @throws GitException When the git execution failed.
  */
 private function getCurrentUserInfo($git)
 {
     // Sadly no command in our git library for this.
     $processBuilder = new ProcessBuilder();
     $processBuilder->setWorkingDirectory($git->getRepositoryPath());
     $processBuilder->add($git->getConfig()->getGitExecutablePath())->add('config')->add('--get-regexp')->add('user.[name|email]');
     $process = $processBuilder->getProcess();
     $git->getConfig()->getLogger()->debug(sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()));
     $process->run();
     $output = rtrim($process->getOutput(), "\r\n");
     if (!$process->isSuccessful()) {
         throw GitException::createFromProcess('Could not execute git command', $process);
     }
     $config = array();
     foreach (explode(PHP_EOL, $output) as $line) {
         list($name, $value) = explode(' ', $line, 2);
         $config[trim($name)] = trim($value);
     }
     if (isset($config['user.name']) && $config['user.email']) {
         return sprintf('%s <%s>', $config['user.name'], $config['user.email']);
     }
     return '';
 }
 /**
  * @covers \ContaoCommunityAlliance\BuildSystem\Repository\GitRepository::tag
  * @covers \ContaoCommunityAlliance\BuildSystem\Repository\Command\TagCommandBuilder::execute
  */
 public function testTagOnUninitializedRepository()
 {
     $this->setExpectedException('ContaoCommunityAlliance\\BuildSystem\\Repository\\GitException');
     $this->uninitializedGitRepository->tag()->execute('unit-test');
 }