| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 | 6 |
| 7 from webkitpy.w3c.local_wpt import LocalWPT | 7 from webkitpy.w3c.local_wpt import LocalWPT |
| 8 from webkitpy.w3c.common import exportable_commits_since | 8 from webkitpy.w3c.common import exportable_commits_since |
| 9 from webkitpy.w3c.wpt_github import WPTGitHub |
| 9 | 10 |
| 10 _log = logging.getLogger(__name__) | 11 _log = logging.getLogger(__name__) |
| 11 | 12 |
| 12 | 13 |
| 13 class TestExporter(object): | 14 class TestExporter(object): |
| 14 | 15 |
| 15 def __init__(self, host, wpt_github, dry_run=False): | 16 def __init__(self, host, gh_user, gh_token, dry_run=False): |
| 16 self.host = host | 17 self.host = host |
| 17 self.wpt_github = wpt_github | 18 self.wpt_github = WPTGitHub(host, gh_user, gh_token) |
| 18 self.dry_run = dry_run | 19 self.dry_run = dry_run |
| 19 self.local_wpt = LocalWPT(self.host) | 20 self.local_wpt = LocalWPT(self.host, gh_token) |
| 20 self.local_wpt.fetch() | 21 self.local_wpt.fetch() |
| 21 | 22 |
| 22 def run(self): | 23 def run(self): |
| 23 """Query in-flight pull requests, then merge PR or create one. | 24 """Query in-flight pull requests, then merge PR or create one. |
| 24 | 25 |
| 25 This script assumes it will be run on a regular interval. On | 26 This script assumes it will be run on a regular interval. On |
| 26 each invocation, it will either attempt to merge or attempt to | 27 each invocation, it will either attempt to merge or attempt to |
| 27 create a PR, never both. | 28 create a PR, never both. |
| 28 """ | 29 """ |
| 29 pull_requests = self.wpt_github.in_flight_pull_requests() | 30 pull_requests = self.wpt_github.in_flight_pull_requests() |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 response_data = self.wpt_github.create_pr( | 107 response_data = self.wpt_github.create_pr( |
| 107 remote_branch_name=remote_branch_name, | 108 remote_branch_name=remote_branch_name, |
| 108 desc_title=outbound_commit.subject(), | 109 desc_title=outbound_commit.subject(), |
| 109 body=outbound_commit.body()) | 110 body=outbound_commit.body()) |
| 110 | 111 |
| 111 _log.info('Create PR response: %s', response_data) | 112 _log.info('Create PR response: %s', response_data) |
| 112 | 113 |
| 113 if response_data: | 114 if response_data: |
| 114 data, status_code = self.wpt_github.add_label(response_data['number'
]) | 115 data, status_code = self.wpt_github.add_label(response_data['number'
]) |
| 115 _log.info('Add label response (status %s): %s', status_code, data) | 116 _log.info('Add label response (status %s): %s', status_code, data) |
| OLD | NEW |