protected function githubCommitRequest(Project $project, array $payload)
    {
        // Github sends a payload when you close a pull request with a
        // non-existent commit. We don't want this.
        if (array_key_exists('after', $payload) && $payload['after'] === '0000000000000000000000000000000000000000') {
            return array('status' => 'ignored');
        }

        if (isset($payload['commits']) && is_array($payload['commits'])) {
            // If we have a list of commits, then add them all as builds to be tested:

            $results = array();
            $status = 'failed';
            foreach ($payload['commits'] as $commit) {
                if (!$commit['distinct']) {
                    $results[$commit['id']] = array('status' => 'ignored');
                    continue;
                }

                try {
                    $branch = str_replace('refs/heads/', '', $payload['ref']);
                    $committer = $commit['committer']['email'];
                    $results[$commit['id']] = $this->createBuild(
                        $project,
                        $commit['id'],
                        $branch,
                        $committer,
                        $commit['message']
                    );
                    $status = 'ok';
                } catch (Exception $ex) {
                    $results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
                }
            }
            return array('status' => $status, 'commits' => $results);
        }

        if (substr($payload['ref'], 0, 10) == 'refs/tags/') {
            // If we don't, but we're dealing with a tag, add that instead:
            $branch = str_replace('refs/tags/', 'Tag: ', $payload['ref']);
            $committer = $payload['pusher']['email'];
            $message = $payload['head_commit']['message'];
            return $this->createBuild($project, $payload['after'], $branch, $committer, $message);
        }

        return array('status' => 'ignored', 'message' => 'Unusable payload.');
    }
protected function githubCommitRequest(Project $project, array $payload)
    {
        // Github sends a payload when you close a pull request with a
        // non-existent commit. We don't want this.
        if (array_key_exists('after', $payload) && $payload['after'] === '0000000000000000000000000000000000000000') {
            return array('status' => 'ignored');
        }

        if (isset($payload['commits']) && is_array($payload['commits'])) {
            // If we have a list of commits, then add them all as builds to be tested:

            $results = array();
            $status = 'failed';
            foreach ($payload['commits'] as $commit) {
                if (!$commit['distinct']) {
                    $results[$commit['id']] = array('status' => 'ignored');
                    continue;
                }

                try {
                    $branch = str_replace('refs/heads/', '', $payload['ref']);
                    $committer = $commit['committer']['email'];
                    $results[$commit['id']] = $this->createBuild(
                        $project,
                        $commit['id'],
                        $branch,
                        $committer,
                        $commit['message']
                    );
                    $status = 'ok';
                } catch (Exception $ex) {
                    $results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
                }
            }
            return array('status' => $status, 'commits' => $results);
        }

        if (substr($payload['ref'], 0, 10) == 'refs/tags/') {
            // If we don't, but we're dealing with a tag, add that instead:
            $branch = str_replace('refs/tags/', 'Tag: ', $payload['ref']);
            $committer = $payload['pusher']['email'];
            $message = $payload['head_commit']['message'];
            return $this->createBuild($project, $payload['after'], $branch, $committer, $message);
        }

        return array('status' => 'ignored', 'message' => 'Unusable payload.');
    }
protected function githubCommitRequest ( Project $ project , array $ payload ) { // Github sends a payload when you close a pull request with a // non-existent commit. We don't want this. if ( array_key_exists ( 'after' , $ payload ) && $ payload [ 'after' ] === '0000000000000000000000000000000000000000' ) { return array ( 'status' => 'ignored' ) ; } if ( isset ( $ payload [ 'commits' ] ) && is_array ( $ payload [ 'commits' ] ) ) { // If we have a list of commits, then add them all as builds to be tested: $ results = array ( ) ; $ status = 'failed' ; foreach ( $ payload [ 'commits' ] as $ commit ) { if ( ! $ commit [ 'distinct' ] ) { $ results [ $ commit [ 'id' ] ] = array ( 'status' => 'ignored' ) ; continue ; } try { $ branch = str_replace ( 'refs/heads/' , '' , $ payload [ 'ref' ] ) ; $ committer = $ commit [ 'committer' ] [ 'email' ] ; $ results [ $ commit [ 'id' ] ] = $ this -> createBuild ( $ project , $ commit [ 'id' ] , $ branch , $ committer , $ commit [ 'message' ] ) ; $ status = 'ok' ; } catch ( Exception $ ex ) { $ results [ $ commit [ 'id' ] ] = array ( 'status' => 'failed' , 'error' => $ ex -> getMessage ( ) ) ; } } return array ( 'status' => $ status , 'commits' => $ results ) ; } if ( substr ( $ payload [ 'ref' ] , 0 , 10 ) == 'refs/tags/' ) { // If we don't, but we're dealing with a tag, add that instead: $ branch = str_replace ( 'refs/tags/' , 'Tag: ' , $ payload [ 'ref' ] ) ; $ committer = $ payload [ 'pusher' ] [ 'email' ] ; $ message = $ payload [ 'head_commit' ] [ 'message' ] ; return $ this -> createBuild ( $ project , $ payload [ 'after' ] , $ branch , $ committer , $ message ) ; } return array ( 'status' => 'ignored' , 'message' => 'Unusable payload.' ) ; }
Handle the payload when Github sends a commit webhook.

@param Project $project
@param array $payload
@param b8\Http\Response\JsonResponse $response

@return b8\Http\Response\JsonResponse
Handle the payload when Github sends a commit webhook .