Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1273)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py

Issue 2518313003: Refactor WPT Export to ensure only one PR in flight at a time (Closed)
Patch Set: Address CL feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
deleted file mode 100644
index 49a4a7618225eafd34331f4da185497dca753d14..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/github.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import base64
-import json
-import httplib2
-import logging
-
-_log = logging.getLogger(__name__)
-
-
-class GitHub(object):
-
- def __init__(self, host):
- self.host = host
- self.user = self.host.environ.get('GH_USER')
- self.token = self.host.environ.get('GH_TOKEN')
-
- assert self.user and self.token, 'must have GH_USER and GH_TOKEN env vars'
-
- def auth_token(self):
- return base64.encodestring('{}:{}'.format(self.user, self.token))
-
- def create_pr(self, local_branch_name, desc_title, body):
- """Creates a PR on GitHub.
-
- API doc: https://developer.github.com/v3/pulls/#create-a-pull-request
-
- Returns:
- A raw response object if successful, None if not.
- """
- assert local_branch_name
- assert desc_title
- assert body
-
- pr_branch_name = '{}:{}'.format(self.user, local_branch_name)
-
- # TODO(jeffcarp): add HTTP to Host and use that here
- conn = httplib2.Http()
- headers = {
- "Accept": "application/vnd.github.v3+json",
- "Authorization": "Basic " + self.auth_token()
- }
- body = {
- "title": desc_title,
- "body": body,
- "head": pr_branch_name,
- "base": "master"
- }
- resp, content = conn.request("https://api.github.com/repos/w3c/web-platform-tests/pulls",
- "POST", body=json.JSONEncoder().encode(body), headers=headers)
- _log.info("GitHub response: %s", content)
- if resp["status"] != "201":
- return None
- return json.loads(content)

Powered by Google App Engine
This is Rietveld 408576698