| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """A utility class for interacting with the Chromium git tree |
| 6 for use cases relating to the Web Platform Tests. |
| 7 """ |
| 8 |
| 9 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' |
| 10 |
| 11 from webkitpy.common.memoized import memoized |
| 12 from webkitpy.common.webkit_finder import WebKitFinder |
| 13 |
| 14 |
| 15 class ChromiumWPT(object): |
| 16 |
| 17 def __init__(self, host): |
| 18 """ |
| 19 Args: |
| 20 host: A Host object. |
| 21 """ |
| 22 self.host = host |
| 23 |
| 24 def exportable_commits_since(self, chromium_commit): |
| 25 chromium_commits = self.chromium_commits_since(chromium_commit) |
| 26 |
| 27 def is_exportable(chromium_commit): |
| 28 return self.has_changes_in_wpt(chromium_commit) and not self.is_impo
rt_commit(chromium_commit) |
| 29 |
| 30 return filter(is_exportable, chromium_commits) |
| 31 |
| 32 def is_import_commit(self, chromium_commit): |
| 33 return self.subject(chromium_commit).startswith('Import wpt@') |
| 34 |
| 35 def has_changes_in_wpt(self, chromium_commit): |
| 36 """Detects if a Chromium revision has modified files in the WPT director
y.""" |
| 37 |
| 38 assert chromium_commit |
| 39 files = self.host.executive.run_command([ |
| 40 'git', 'diff-tree', '--no-commit-id', |
| 41 '--name-only', '-r', chromium_commit |
| 42 ]).splitlines() |
| 43 |
| 44 # TODO(jeffcarp): Use DepsUpdater.is_baseline |
| 45 return any(f.startswith(CHROMIUM_WPT_DIR) and '-expected' not in f for f
in files) |
| 46 |
| 47 def chromium_commits_since(self, chromium_commit): |
| 48 return self.host.executive.run_command([ |
| 49 'git', 'rev-list', '--reverse', '{}..HEAD'.format(chromium_commit) |
| 50 ]).splitlines() |
| 51 |
| 52 def subject(self, chromium_commit): |
| 53 return self.host.executive.run_command([ |
| 54 'git', 'show', '--format=%s', '--no-patch', chromium_commit |
| 55 ]) |
| 56 |
| 57 def commit_position(self, chromium_commit): |
| 58 return self.host.executive.run_command([ |
| 59 'git', 'footers', '--position', chromium_commit |
| 60 ]) |
| 61 |
| 62 def message(self, chromium_commit): |
| 63 """Returns a string with a commit's subject and body.""" |
| 64 return self.host.executive.run_command([ |
| 65 'git', 'show', '--format=%B', '--no-patch', chromium_commit |
| 66 ]) |
| 67 |
| 68 def format_patch(self, chromium_commit): |
| 69 """Makes a patch with just changes in files in the WPT for a given commi
t.""" |
| 70 # TODO(jeffcarp): do not include expectations files |
| 71 return self.host.executive.run_command([ |
| 72 'git', 'format-patch', '-1', '--stdout', |
| 73 chromium_commit, self.absolute_chromium_wpt_dir() |
| 74 ]) |
| 75 |
| 76 @memoized |
| 77 def absolute_chromium_wpt_dir(self): |
| 78 finder = WebKitFinder(self.host.filesystem) |
| 79 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt') |
| OLD | NEW |