Beispiel #1
0
 /**
  * (non-PHPdoc)
  * @see Symfony\Component\Console\Command.Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Load configuration file
     $configPath = $input->getOption('config');
     if (null === $configPath) {
         $configPath = $this->getDefaultConfigPath();
     }
     try {
         $config = $this->loadConfig($configPath);
     } catch (Exception $exception) {
         $output->writeln($exception->getMessage());
         exit(1);
     }
     // Let's assume configuration file is at the root of the project local repository
     // TODO: Allow to set path to the repository in the configuration file
     $projectPath = dirname($configPath);
     // The only VCS supported is Git for now so there is no choice
     // TODO: Support more VCS
     $vcs = new GitDriver($projectPath);
     $commit = $vcs->getCommit($input->getArgument('hash'));
     // Build commit
     $builder = new Builder($config);
     $report = $builder->buildCommit($commit);
     // Prepare event to be broadcasted
     $event = new Event();
     $title = $report->isSuccessfull() ? 'Build succeed' : 'Build failed';
     $event->setTitle($title);
     // Broadcast report
     // TODO: Allow to define notifiers in the configuration file
     $notifier = new GrowlNotifier();
     $notifier->handleEvent($event);
 }