def get_commit_info(app, payload):
    if 'pull_request' in payload:
        commit_sha = payload['pull_request']['head']['sha']
        status_url = payload['pull_request']['statuses_url']
    
    elif 'head_commit' in payload:
        commit_sha = payload['head_commit']['id']
        status_url = payload['repository']['statuses_url']
        status_url = expand_uri(status_url, dict(sha=commit_sha))
    
    else:
        raise ValueError('Unintelligible payload')
    
    if 'repository' not in payload:
        raise ValueError('Unintelligible payload')

    repo = payload['repository']
    owner = repo['owner'].get('name') or repo['owner'].get('login')
    repository = repo['name']
    
    app.logger.debug('Status URL {}'.format(status_url))
    
    return owner, repository, commit_sha, status_url
Get owner, repository, commit SHA and Github status API URL from webhook payload.
dataset/ETHPy150Open openaddresses/machine/openaddr/ci/__init__.py/get_commit_info