public function execute(Event $event = null)
    {
        $event = $event ? $event : $this->createEvent();
        $this->logger->info('Starting web hook handle');

        if (!$event->isValid()) {
            $this->logger->error('Found not valid event from '.$event->getHost());
            $this->return404();

            return;
        }

        if (!$this->checkPermissions($event, $this->options)) {
            return;
        }

        $repoName = $event->getRepositoryName();
        $branchName = $event->getBranchName();
        $repository = $this->getRepository($repoName);
        if (!$repository || !($branch = $repository->getBranch($branchName))) {
            $this->logger->warning('Repository: '.$repoName.' and branch: '.$branchName.' not found in the settings');
            $this->return404();

            return;
        }

        $commandResults = $this->commandExecutor->execute(array($this, $repository, $branch));
        $this->sendEmails($event, $commandResults);

        $this->logger->info('End of web hook handle');
    }