| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
|
| similarity index 52%
|
| rename from third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
|
| rename to third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
|
| index 49a4a7618225eafd34331f4da185497dca753d14..c648dc0b1753ae45c5e6bf07283a9585e56174cb 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_github.py
|
| @@ -8,9 +8,11 @@ import httplib2
|
| import logging
|
|
|
| _log = logging.getLogger(__name__)
|
| +API_BASE = 'https://api.github.com'
|
| +EXPORT_LABEL = 'chromium-export'
|
|
|
|
|
| -class GitHub(object):
|
| +class WPTGitHub(object):
|
|
|
| def __init__(self, host):
|
| self.host = host
|
| @@ -36,6 +38,7 @@ class GitHub(object):
|
|
|
| pr_branch_name = '{}:{}'.format(self.user, local_branch_name)
|
|
|
| + # TODO(jeffcarp): CC foolip and qyearsley on all PRs for now
|
| # TODO(jeffcarp): add HTTP to Host and use that here
|
| conn = httplib2.Http()
|
| headers = {
|
| @@ -46,7 +49,8 @@ class GitHub(object):
|
| "title": desc_title,
|
| "body": body,
|
| "head": pr_branch_name,
|
| - "base": "master"
|
| + "base": 'master',
|
| + "labels": [EXPORT_LABEL]
|
| }
|
| resp, content = conn.request("https://api.github.com/repos/w3c/web-platform-tests/pulls",
|
| "POST", body=json.JSONEncoder().encode(body), headers=headers)
|
| @@ -54,3 +58,40 @@ class GitHub(object):
|
| if resp["status"] != "201":
|
| return None
|
| return json.loads(content)
|
| +
|
| + def in_flight_pull_requests(self):
|
| + url_encoded_label = EXPORT_LABEL.replace(' ', '%20')
|
| + path = '/search/issues?q=repo:w3c/web-platform-tests%20is:open%20type:pr%20labels:{}'.format(url_encoded_label)
|
| + response, content = self.request(path)
|
| + if response['status'] == '200':
|
| + data = json.loads(content)
|
| + return data['items']
|
| + else:
|
| + raise Exception('Non-200 status code (%s): %s' % (response['status'], content))
|
| +
|
| + def request(self, path, body=None):
|
| + assert path.startswith('/')
|
| +
|
| + # Not used yet since only hitting public API
|
| + # headers = {
|
| + # "Accept": "application/vnd.github.v3+json",
|
| + # "Authorization": "Basic " + self.auth_token()
|
| + # }
|
| +
|
| + if body:
|
| + json_body = json.dumps(body)
|
| + else:
|
| + json_body = None
|
| +
|
| + conn = httplib2.Http()
|
| + return conn.request(API_BASE + path, body=json_body)
|
| +
|
| + def merge_pull_request(self, pull_request_number):
|
| + path = '/repos/w3c/web-platform-tests/pulls/%d/merge' % pull_request_number
|
| + body = {}
|
| + response, content = self.request(path, body)
|
| +
|
| + if response['status'] == '200':
|
| + return json.loads(content)
|
| + else:
|
| + raise Exception('PR could not be merged: %d' % pull_request_number)
|
|
|