/** * {@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']); }
/** * {@inheritdoc} * @throws RepositoryNotFoundException */ public function isApplicable($payload) { // Handle only created action if ('created' !== $payload->action) { return false; } // Handle only pull requests if (!isset($payload->issue->pull_request)) { return false; } // Handle only comments with status markers if (null === $this->statusMarkerHelper->getStatusMarker($payload->comment->body)) { return false; } $fullName = $payload->repository->full_name; $repository = $this->getRepositoryRepository()->findByFullName($fullName); if (null === $repository || !$repository->getEnabled()) { throw new RepositoryNotFoundException(); } list($ownerName, $repoName) = explode('/', $payload->repository->full_name, 2); return $this->githubApiHelper->checkCollaborator($repository->getOwner()->getAccessToken(), $ownerName, $repoName, $payload->comment->user->login); }