Exemple #1
0
def main():
    event_json = request.get_json()
    if event_warrants_label_check(event_json):
        pull_request = PullRequest(event_json)
        print("Checking labels for PR {}".format(pull_request.issue_url))
        status_code = pull_request.compute_and_post_status(REQUIRED_LABELS_ANY, REQUIRED_LABELS_ALL, BANNED_LABELS)
        return str(status_code)
    else:
        return 'No label check needed'
Exemple #2
0
def main():
    event_json = request.get_json()
    if event_warrants_label_check(event_json):
        pull_request = PullRequest(event_json)
        print("Checking labels for PR {}".format(pull_request.issue_url))
        status_code = pull_request.compute_and_post_status(
            CONFIG['required_any'], CONFIG['required_all'], CONFIG['banned'])
        return str(status_code)
    else:
        return 'No label check needed'
Exemple #3
0
def main():
    event_json = request.get_json()
    if event_warrants_label_check(event_json):
        pull_request = PullRequest(event_json)
        print("Checking labels for PR {}".format(pull_request.issue_url))
        status_code = pull_request.compute_and_post_status(
            CONFIG['required_any'], CONFIG['required_all'], CONFIG['banned'])
        return str(status_code)
    else:
        return 'No label check needed'
 def test_it_fallback_to_login_password_authentication_with_no_token(self,
                                                                     get_token,
                                                                     get_credentials):
     get_token.side_effect = NoGitHubTokenException
     PullRequest({'pull_request': {'issue_url': 'https/github/orga/url/issueurl'}})
     get_token.assert_called_once()
     get_credentials.assert_called_once()
 def test_it_use_login_token_authentication(self,
                                            get_token,
                                            get_credentials):
     get_credentials.return_value = ('myuser', 'mypass')
     PullRequest({'pull_request': {'issue_url': 'https/github/orga/url/issueurl'}})
     get_token.assert_called_once()
     get_credentials.assert_not_called()
 def test_it_calls_proxy_config_during_init(self, get_proxy):
     get_proxy.return_value = 'https://ghproxy.github.com/api/v3/'
     pr = PullRequest({
         'pull_request': {
             'issue_url': 'https://api.github.com/orga/url/issueurl'
         }
     })
     self.assertEqual(pr.github_proxy, 'https://ghproxy.github.com/api/v3/')
 def test_it_gets_patched_label_urls(self, get_proxy):
     get_proxy.return_value = 'https://ghproxy.github.com/api/v3/'
     pr = PullRequest({
         'pull_request': {
             'issue_url': 'https://api.github.com/orga/url/issueurl'
         }
     })
     self.assertEqual(
         pr.label_url,
         'https://ghproxy.github.com/api/v3/orga/url/issueurl/labels')
 def test_it_uses_proxy_status_url(self, get_proxy):
     get_proxy.return_value = 'https://ghproxy.github.com/api/v3/'
     pr = PullRequest({
         'pull_request': {
             'statuses_url': 'https://api.github.com/orga/url/statuses_url',
             'issue_url': 'https://api.github.com/orga/url/issueurl'
         }
     })
     self.assertEqual(
         pr.statuses_url,
         'https://ghproxy.github.com/api/v3/orga/url/statuses_url')
Exemple #9
0
def main():
    event_json = request.get_json()
    signature = request.headers['X-Hub-Signature'].split('=')[1]
    REQUIRED_ALL = request.args.get('required_all')
    REQUIRED_ANY = request.args.get('required_any')
    BANNED = request.args.get('banned')

    if not webhook_signature_is_valid(GITHUB_SECRET, request.data, signature):
        return Response(
        'Could not verify your access level for that URL.\n',
        401)

    if event_warrants_label_check(event_json):
        pull_request = PullRequest(event_json)
        print("Checking labels for PR {}".format(pull_request.issue_url))
        if REQUIRED_ALL or REQUIRED_ANY:
            status_code = pull_request.compute_and_post_status(REQUIRED_ALL, REQUIRED_ANY, BANNED)
        else:
            status_code = pull_request.compute_and_post_status(REQUIRED_LABELS_ANY, REQUIRED_LABELS_ALL, BANNED_LABELS)
        return str(status_code)
    else:
        return 'No label check needed'