/**
  * {@inheritdoc}
  */
 public function handle($payload)
 {
     $fullName = $payload->repository->full_name;
     $repository = $this->getRepositoryRepository()->findByFullName($fullName);
     if (null === $repository) {
         throw new RepositoryNotFoundException();
     }
     list($ownerName, $repoName) = explode('/', $fullName, 2);
     $commit = $this->githubApiHelper->getLastCommitInPR($repository->getOwner()->getAccessToken(), $ownerName, $repoName, $payload->issue->number);
     $context = [];
     $statusMarker = $this->statusMarkerHelper->getStatusMarker($payload->comment->body);
     switch ($this->statusMarkerHelper->getMarkerType($statusMarker)) {
         case StatusMarkerHelper::APPROVE_TYPE:
             $context['state'] = 'success';
             $context['description'] = 'This PR was reviewed';
             break;
         case StatusMarkerHelper::UNDER_REVIEW_TYPE:
             $context['state'] = 'pending';
             $context['description'] = 'This PR pending code review';
             break;
         case StatusMarkerHelper::REJECT_TYPE:
             $context['state'] = 'failure';
             $context['description'] = 'This PR was rejected';
             break;
         default:
             return;
     }
     $this->githubApiHelper->createStatus($repository, $commit['sha'], $context);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  * @throws RepositoryNotFoundException
  */
 public function handle($payload)
 {
     $fullName = $payload->pull_request->base->repo->full_name;
     $commitSha = $payload->pull_request->head->sha;
     $repository = $this->getRepositoryRepository()->findByFullName($fullName);
     if (null === $repository || !$repository->getEnabled()) {
         throw new RepositoryNotFoundException();
     }
     $this->githubApiHelper->createStatus($repository, $commitSha, ['state' => 'pending', 'description' => 'This PR pending code review']);
 }