@WebApp.route('/hook/')
def hook(request):
    logger = logging.getLogger(__name__ + '.hook')
    app = request.app.app
    assert request.mimetype == 'application/json'
    data = request.data
    sig = hmac.new(app.github_client_secret, data, hashlib.sha1)
    assert request.headers['X-Hub-Signature'].split('=')[1] == sig.hexdigest()
    payload = json.loads(data)
    event = request.headers['X-GitHub-Event']
    logger.info('event = %r', event)
    logger.debug('payload = %r', payload)
    if event == 'push':
        message = payload.get('head_commit', {}).get('message', '')
    elif event == 'pull_request':
        try:
            number = payload['pull_request']['number']
        except KeyError:
            message = None
        else:
            pull_request = app.repository.pull_request(number)
            commits = pull_request.iter_commits()
            head = list(commits)[-1]
            message = head._json_data.get('commit', {}).get('message', '')
    else:
        message = None
    if message is None or IGNORE_PATTERN.search(message):
        return 'ignored'
    config_url = app.repository._build_url('contents', app.config_dir,
                                           base_url=app.repository._api)
    config_dir = app.repository._get(config_url.rstrip('/'), params={
        'ref': payload['head_commit']['id']
               if event == 'push'
               else payload['pull_request']['head']['sha']
    })
    logger.info('config_dir.url = %r', config_dir.url)
    logger.info('config_dir.status_code = %r', config_dir.status_code)
    logger.debug('config_dir.json = %r', config_dir.json)
    if 400 >= config_dir.status_code:
        return 'ignored'
    if event == 'pull_request':
        hook_pull_request(request.app, payload)
    elif event == 'push':
        hook_push(request.app, payload)
    return 'okay'
dataset/ETHPy150Open crosspop/asuka/asuka/web.py/hook/swapped operands of `>=`