| 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 from webkitpy.w3c.local_wpt import LocalWPT | 6 from webkitpy.w3c.local_wpt import LocalWPT |
| 7 from webkitpy.w3c.chromium_wpt import ChromiumWPT | 7 from webkitpy.w3c.chromium_wpt import ChromiumWPT |
| 8 from webkitpy.w3c.chromium_commit import ChromiumCommit | 8 from webkitpy.w3c.chromium_commit import ChromiumCommit |
| 9 | 9 |
| 10 _log = logging.getLogger(__name__) | 10 _log = logging.getLogger(__name__) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 _log.info(pull_request['title']) | 28 _log.info(pull_request['title']) |
| 29 | 29 |
| 30 # TODO(jeffcarp): Check the PR status here | 30 # TODO(jeffcarp): Check the PR status here |
| 31 | 31 |
| 32 if self.dry_run: | 32 if self.dry_run: |
| 33 _log.info('[dry_run] Would have attempted to merge PR') | 33 _log.info('[dry_run] Would have attempted to merge PR') |
| 34 else: | 34 else: |
| 35 _log.info('Merging...') | 35 _log.info('Merging...') |
| 36 self.wpt_github.merge_pull_request(pull_request['number']) | 36 self.wpt_github.merge_pull_request(pull_request['number']) |
| 37 _log.info('PR merged!') | 37 _log.info('PR merged!') |
| 38 # TODO(jeffcarp): Delete remote branch after merging |
| 39 |
| 40 # The script needs to stop here since the Chromium |
| 41 # WPT mirror lags behind a little bit. Also, it's probably safer |
| 42 # to not be merging and creating a PR in the same run. |
| 43 return |
| 38 elif len(pull_requests) > 1: | 44 elif len(pull_requests) > 1: |
| 39 _log.error(pull_requests) | 45 _log.error(pull_requests) |
| 40 # TODO(jeffcarp): Print links to PRs | 46 # TODO(jeffcarp): Print links to PRs |
| 41 raise Exception('More than two in-flight PRs!') | 47 raise Exception('More than two in-flight PRs!') |
| 42 | 48 |
| 43 # Second, look for exportable commits in Chromium | 49 # Second, look for exportable commits in Chromium |
| 44 # At this point, no in-flight PRs should exist | 50 # At this point, no in-flight PRs should exist |
| 45 # If there was an issue merging, it should have errored out | 51 # If there was an issue merging, it should have errored out |
| 46 local_wpt = LocalWPT(self.host, use_github=False) | 52 local_wpt = LocalWPT(self.host, use_github=True) |
| 47 chromium_wpt = ChromiumWPT(self.host) | 53 chromium_wpt = ChromiumWPT(self.host) |
| 48 | 54 |
| 49 # TODO(jeffcarp): have the script running this fetch Chromium origin/mas
ter | 55 # TODO(jeffcarp): have the script running this fetch Chromium origin/mas
ter |
| 50 # TODO(jeffcarp): move WPT fetch out of its constructor to match planned
ChromiumWPT pattern | 56 # TODO(jeffcarp): move WPT fetch out of its constructor to match planned
ChromiumWPT pattern |
| 51 | 57 |
| 52 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit() | 58 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit() |
| 53 assert chromium_commit, 'No Chromium commit found, this is impossible' | 59 assert chromium_commit, 'No Chromium commit found, this is impossible' |
| 54 | 60 |
| 55 wpt_behind_master = local_wpt.commits_behind_master(wpt_commit) | 61 wpt_behind_master = local_wpt.commits_behind_master(wpt_commit) |
| 56 | 62 |
| 57 _log.info('\nLast Chromium export commit in web-platform-tests:') | 63 _log.info('\nLast Chromium export commit in web-platform-tests:') |
| 58 _log.info('web-platform-tests@%s', wpt_commit) | 64 _log.info('web-platform-tests@%s', wpt_commit) |
| 59 _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_mas
ter) | 65 _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_mas
ter) |
| 60 | 66 |
| 61 _log.info('\nThe above WPT commit points to the following Chromium commi
t:') | 67 _log.info('\nThe above WPT commit points to the following Chromium commi
t:') |
| 62 _log.info('chromium@%s', chromium_commit.sha) | 68 _log.info('chromium@%s', chromium_commit.sha) |
| 63 _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behi
nd_master()) | 69 _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behi
nd_master()) |
| 64 | 70 |
| 65 # TODO(jeffcarp): Have this function return ChromiumCommits | 71 # TODO(jeffcarp): Have this function return ChromiumCommits |
| 66 exportable_commits = chromium_wpt.exportable_commits_since(chromium_comm
it.sha) | 72 exportable_commits = chromium_wpt.exportable_commits_since(chromium_comm
it.sha) |
| 67 | 73 |
| 74 def has_patch(commit): |
| 75 # TODO(jeffcarp): now do a test comparison of patch against local WP
T |
| 76 # TODO(jeffcarp): dedupe from format_patch below |
| 77 outbound_commit = ChromiumCommit(self.host, sha=commit) |
| 78 patch = outbound_commit.format_patch() |
| 79 output = local_wpt.test_patch(patch) |
| 80 return bool(output) |
| 81 |
| 82 exportable_commits = filter(has_patch, exportable_commits) |
| 83 |
| 68 if not exportable_commits: | 84 if not exportable_commits: |
| 69 _log.info('No exportable commits found in Chromium, stopping.') | 85 _log.info('No exportable commits found in Chromium, stopping.') |
| 70 return | 86 return |
| 71 | 87 |
| 72 _log.info('Found %d exportable commits in Chromium:', len(exportable_com
mits)) | 88 _log.info('Found %d exportable commits in Chromium:', len(exportable_com
mits)) |
| 73 for commit in exportable_commits: | 89 for commit in exportable_commits: |
| 74 _log.info('- %s %s', commit, chromium_wpt.subject(commit)) | 90 _log.info('- %s %s', commit, chromium_wpt.subject(commit)) |
| 75 | 91 |
| 76 outbound_commit = ChromiumCommit(self.host, sha=exportable_commits[0]) | 92 outbound_commit = ChromiumCommit(self.host, sha=exportable_commits[0]) |
| 77 _log.info('Picking the earliest commit and creating a PR') | 93 _log.info('Picking the earliest commit and creating a PR') |
| 78 _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject()) | 94 _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject()) |
| 79 | 95 |
| 80 patch = outbound_commit.format_patch() | 96 patch = outbound_commit.format_patch() |
| 81 message = outbound_commit.message() | 97 message = outbound_commit.message() |
| 82 | 98 |
| 83 # TODO: now do a test comparison of patch against local WPT | |
| 84 | |
| 85 if self.dry_run: | 99 if self.dry_run: |
| 86 _log.info('[dry_run] Stopping before creating PR') | 100 _log.info('[dry_run] Stopping before creating PR') |
| 87 _log.info('\n\n[dry_run] message:') | 101 _log.info('\n\n[dry_run] message:') |
| 88 _log.info(message) | 102 _log.info(message) |
| 89 _log.info('\n\n[dry_run] patch:') | 103 _log.info('\n\n[dry_run] patch:') |
| 90 _log.info(patch) | 104 _log.info(patch) |
| 91 return | 105 return |
| 92 | 106 |
| 93 local_branch_name = local_wpt.create_branch_with_patch(message, patch) | 107 local_branch_name = local_wpt.create_branch_with_patch(message, patch) |
| 94 | 108 |
| 95 self.wpt_github.create_pr( | 109 self.wpt_github.create_pr( |
| 96 local_branch_name=local_branch_name, | 110 local_branch_name=local_branch_name, |
| 97 desc_title=outbound_commit.subject(), | 111 desc_title=outbound_commit.subject(), |
| 98 body=outbound_commit.body()) | 112 body=outbound_commit.body()) |
| 113 |
| 114 # TODO(jeffcarp): Create a comment on the PR to CC foolip and qyearsley |
| OLD | NEW |