/**
  * @param \Mrimann\CoMo\Domain\Model\Repository $repository
  */
 protected function processSingleRepository(\Mrimann\CoMo\Domain\Model\Repository $repository)
 {
     // prepare local cached clone for remote repositories if we're not on a local repo
     if ($repository->isLocalRepository() === FALSE) {
         $workingDirectory = $this->getCachePath($repository);
         $this->outputLine('-> working directory is: ' . $workingDirectory);
         $preparationResult = $this->prepareCachedClone($repository, $workingDirectory);
         if ($preparationResult === TRUE) {
             $this->outputLine('-> cached clone is ready to rumble...');
         } else {
             $this->outputLine('-> preparing local cache failed somehow, giving up on this repo.');
             return;
         }
     } else {
         $this->outputLine('-> OK, a local repository - just using that directory, no clone or pulling needed.');
         $workingDirectory = $repository->getUrl();
         $this->outputLine('-> working directory is: ' . $workingDirectory);
     }
     $lastProcessedHash = $this->extractCommits($repository);
     if ($lastProcessedHash != '') {
         $repository->setLastProcessedCommit($lastProcessedHash);
         $this->repositoryRepository->update($repository);
     }
     $this->outputLine('-> finished extracting the commits.');
     $this->outputLine('-------------------');
 }
Esempio n. 2
0
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     $monthIdentifier = $this->electomatService->getMonthIdentifierLastMonth();
     $this->view->assign('numberOfCommits', $this->commitRepository->getCommitsByMonth($monthIdentifier)->count());
     $this->view->assign('numberOfActiveRepositories', $this->repositoryRepository->extractTheRepositoriesFromAStackOfCommits($this->commitRepository->getCommitsByMonth($monthIdentifier))->count());
     $this->view->assign('numberOfMonitoredRepositories', $this->repositoryRepository->countByIsActive(TRUE));
     $this->view->assign('numberOfCommitters', $this->aggregatedDataPerUserRepository->findNumberOfCommittersPerMonth($monthIdentifier));
     $this->view->assign('coderOfTheMonthAward', $this->awardRepository->findLatestAwards(1)->getFirst());
     $this->view->assign('currentTopicAwards', $this->awardRepository->findCurrentTopicAwards());
 }
 /**
  * RepoDetector for Gitweb
  *
  * Use this command to read a list of repos from a Gitweb "website" and add those repositories
  * to the database for further processing afterwards.
  *
  * Call this with the URL to your Gitweb-Frontend, e.g. http://git.company.tld/ and the base-URL
  * for the access to the Git repositories, could be e.g. "ssh://git@git.company.tld/" (if you're
  * using Gitolite or the like).
  *
  * By default, any newly found repository will *not* directly be marked as active.
  *
  * If you're running CoMo on the same server that hosts your Git repositories, you can prefix
  * the repo's local path with "file://" and CoMo will not try to create a local clone before
  * going to extract the commits of that repository.
  *
  * @param string $url The URL to Gitweb
  * @param string $baseUrl The base URL that is put in front of the single repo's path
  * @param boolean whether the found repos should be marked active, defaults to false
  * @param boolean whether the script should avoid any output
  * @return void
  */
 public function fetchReposCommand($url, $baseUrl, $markAsActive = FALSE, $quiet = FALSE)
 {
     $this->quiet = $quiet;
     $url = $url . '?a=project_index';
     if (!@fopen($url, r)) {
         throw new \TYPO3\Flow\Exception(sprintf('Whoops - somehow I failed to open the list. Try if you can open that URL "%s"', $url));
     }
     $this->baseUrl = $baseUrl;
     $this->outputLine('OK, list fetched from "%s"', array($url));
     $this->outputLine('Base-URL set to: %s', array($this->baseUrl));
     // split the list
     $list = fopen($url, 'r');
     // Read list of repositories from the Gitweb output
     $repoList = file_get_contents($url);
     $repositoryLines = explode("\n", $repoList);
     if (empty($repositoryLines)) {
         $this->outputLine('No repos found, exiting.');
         return;
     }
     // eliminate empty lines first
     foreach ($repositoryLines as $line) {
         if ($line != '') {
             $repoLines[] = $line;
         }
     }
     $this->outputLine('Found %s repositories.', array(count($repoLines)));
     // process each single repository
     $addedCount = 0;
     $skippedCount = 0;
     foreach ($repoLines as $repoLine) {
         $title = $this->getRepoTitleFromRepoLine($repoLine);
         $repoUrl = $this->buildRepoUrl($repoLine);
         if ($this->repositoryRepository->countByUrl($repoUrl) == 0) {
             $repo = new \Mrimann\CoMo\Domain\Model\Repository();
             $repo->setUrl($repoUrl);
             $repo->setTitle($title);
             // only mark the repo as active if this was requested
             if ($markAsActive == TRUE) {
                 $repo->setIsActive(TRUE);
             }
             // Add repository to the database
             $this->repositoryRepository->add($repo);
             $addedCount++;
             $this->outputLine('-> added repository "%s"', array($repoUrl));
         } else {
             $skippedCount++;
             $this->outputLine('-| skipped repository "%s" - exists already', array($repoUrl));
         }
     }
     $this->persistenceManager->persistAll();
     // show some summary output
     $this->outputLine('Added %d new repositories, skipped %d repositories.', array($addedCount, $skippedCount));
     $this->outputLine('Now having a total of %d repositories in the system of which %d are marked active to be checked.', array($this->repositoryRepository->countAll(), $this->repositoryRepository->countByIsActive(TRUE)));
 }