Пример #1
0
 public function process()
 {
     $git = new Git($this->repository);
     $parser = new Parser();
     $currentBranch = $git->getCurrentBranch();
     $revisions = $git->getRevisions();
     $count = count($revisions);
     if ($count < 3) {
         return;
     }
     if ($this->progressHelper !== null) {
         $this->progressHelper->start($this->output, count($revisions) - 2);
     }
     for ($i = 1; $i < $count - 1; $i++) {
         $diff = $parser->parse($git->getDiff($revisions[$i - 1]['sha1'], $revisions[$i]['sha1']));
         $git->checkout($revisions[$i]['sha1']);
         $this->processRevision($revisions[$i]['sha1'], $revisions[$i]['message'], $diff, $this->findFiles());
         if ($this->progressHelper !== null) {
             $this->progressHelper->advance();
         }
     }
     $git->checkout($currentBranch);
 }
Пример #2
0
 /**
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|integer null or 0 if everything went fine, or an error code
  */
 private function executeHistory(InputInterface $input, OutputInterface $output)
 {
     $git = new Git($input->getOption('git-repository'));
     $currentBranch = $git->getCurrentBranch();
     $revisions = $git->getRevisions();
     $count = array();
     $progressHelper = NULL;
     if ($input->getOption('progress')) {
         $progressHelper = $this->getHelperSet()->get('progress');
         $progressHelper->start($output, count($revisions));
     }
     foreach ($revisions as $revision) {
         $git->checkout($revision['sha1']);
         $directories = array();
         foreach ($input->getArgument('values') as $value) {
             $directory = realpath($value);
             if ($directory) {
                 $directories[] = $directory;
             }
         }
         $_count = $this->count($directories, $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'), $input->getOption('count-tests'));
         if ($_count) {
             $count[$revision['date']->format(\DateTime::W3C)] = $_count;
         }
         if ($progressHelper !== NULL) {
             $progressHelper->advance();
         }
     }
     $git->checkout($currentBranch);
     if ($progressHelper !== NULL) {
         $progressHelper->finish();
         $output->writeln('');
     }
     if ($input->getOption('log-csv')) {
         $printer = new History();
         $printer->printResult($input->getOption('log-csv'), $count);
     }
 }