Beispiel #1
0
 public function run(Repository $repository, GitSource $source)
 {
     $this->logger = new Logger($repository->getRepository(), array($this->handler));
     $this->logger->info(sprintf('Generate api docs for %s/%s, branch %s: %s', $repository->getOwnerName(), $repository->getRepositoryName(), $repository->getCommitBranch(), $repository->getCommitMessage()));
     $this->generateDocs($repository, $source);
 }
 protected function pushDocs(Repository $repository, Repository $docsRepository, GitSource $source)
 {
     $this->logger->debug('Push docs');
     $process = ProcessBuilder::create(array('git', 'status', '-s'))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess();
     $this->logger->debug('exec ' . $process->getCommandLine());
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput());
     }
     $changes = $process->getOutput();
     if ($changes) {
         $changes = explode("\n", $changes);
         $changes = array_map('trim', $changes);
         $changes = array_filter($changes);
         foreach ($changes as $change) {
             list($status, $file) = explode(' ', $change, 2);
             $process = ProcessBuilder::create(array('git', $status == 'D' ? 'rm' : 'add', $file))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess();
             $this->logger->debug('exec ' . $process->getCommandLine());
             $process->run();
             if (!$process->isSuccessful()) {
                 throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput());
             }
         }
         $process = ProcessBuilder::create(array('git', 'commit', '-m', $repository->getCommitMessage()))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess();
         $this->logger->debug('exec ' . $process->getCommandLine());
         $process->run();
         if (!$process->isSuccessful()) {
             throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput());
         }
     }
     $process = ProcessBuilder::create(array('git', 'push', 'origin', $this->settings['docs-branch']))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess();
     $this->logger->debug('exec ' . $process->getCommandLine());
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput());
     }
 }