Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py |
| index d7217c0999415007a3f5e9ea49322a3559e2f160..9546b0525fdf9faa986080cedfc89e207db9aaeb 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py |
| @@ -7,6 +7,7 @@ |
| import logging |
| from webkitpy.w3c.chromium_commit import ChromiumCommit |
| +from webkitpy.common.system.executive import ScriptError |
| WPT_REPO_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git' |
| WPT_TMP_DIR = '/tmp/wpt' |
| @@ -29,6 +30,7 @@ class LocalWPT(object): |
| """ |
| self.host = host |
| self.path = path |
| + self.branch_name = 'chromium-export-try' |
| if no_fetch: |
| _log.info('Skipping remote WPT fetch') |
| @@ -36,14 +38,15 @@ class LocalWPT(object): |
| if self.host.filesystem.exists(self.path): |
| _log.info('WPT checkout exists at %s, fetching latest', self.path) |
| - self.run(['git', 'fetch', '--all']) |
| + self.run(['git', 'fetch', 'origin']) |
| self.run(['git', 'checkout', 'origin/master']) |
| else: |
| _log.info('Cloning %s into %s', WPT_REPO_URL, self.path) |
| self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self.path]) |
| if use_github and 'github' not in self.run(['git', 'remote']): |
| - raise Exception('Need to set up remote "github"') |
| + raise Exception(('Need to set up remote "github": cd %s && git remote add github ' |
| + 'git@github.com:w3c/web-platform-tests.git') % self.path) |
| def run(self, command, **kwargs): |
| """Runs a command in the local WPT directory.""" |
| @@ -67,6 +70,10 @@ class LocalWPT(object): |
| self.run(['git', 'reset', '--hard', 'HEAD']) |
| self.run(['git', 'clean', '-fdx']) |
| self.run(['git', 'checkout', 'origin/master']) |
| + try: |
| + self.run(['git', 'branch', '-D', self.branch_name]) |
| + except ScriptError: |
| + _log.info('Local branch %s does not exist yet, not deleting', self.branch_name) |
| def all_branches(self): |
| """Returns a list of local and remote branches.""" |
| @@ -81,20 +88,15 @@ class LocalWPT(object): |
| """ |
| self.clean() |
| all_branches = self.all_branches() |
| - branch_name = 'chromium-export-try' |
| - remote_branch_name = 'remotes/github/%s' % branch_name |
| - |
| - if branch_name in all_branches: |
| - _log.info('Local branch %s already exists, deleting', branch_name) |
| - self.run(['git', 'branch', '-D', branch_name]) |
| + remote_branch_name = 'remotes/github/%s' % self.branch_name |
| if remote_branch_name in all_branches: |
| - _log.info('Remote branch %s already exists, deleting', branch_name) |
| + _log.info('Remote branch %s already exists, deleting', remote_branch_name) |
| # TODO(jeffcarp): Investigate what happens when remote branch exists. |
| - self.run(['git', 'push', 'github', ':{}'.format(branch_name)]) |
| + self.run(['git', 'push', 'github', ':{}'.format(remote_branch_name)]) |
| - _log.info('Creating local branch %s', branch_name) |
| - self.run(['git', 'checkout', '-b', branch_name]) |
| + _log.info('Creating local branch %s', self.branch_name) |
| + self.run(['git', 'checkout', '-b', self.branch_name]) |
| # Remove Chromium WPT directory prefix. |
| patch = patch.replace(CHROMIUM_WPT_DIR, '') |
| @@ -102,10 +104,32 @@ class LocalWPT(object): |
| # TODO(jeffcarp): Use git am -p<n> where n is len(CHROMIUM_WPT_DIR.split(/')) |
| # or something not off-by-one. |
| self.run(['git', 'apply', '-'], input=patch) |
| - self.run(['git', 'commit', '-am', message]) |
| - self.run(['git', 'push', 'github', branch_name]) |
| + self.run(['git', 'add', '.']) |
| + self.run(['git', 'commit', '-m', message]) |
| + self.run(['git', 'push', 'github', self.branch_name]) |
| + |
| + return self.branch_name |
| + |
| + def test_patch(self, patch): |
|
qyearsley
2016/12/02 00:38:46
A docstring may be helpful here.
|
| + self.clean() |
| - return branch_name |
| + # Remove Chromium WPT directory prefix. |
| + # TODO(jeffcarp): dedupe |
| + patch = patch.replace(CHROMIUM_WPT_DIR, '') |
| + print 'the PATCH' |
| + print patch |
|
qyearsley
2016/12/02 00:38:46
Are these meant to be left in? If so, they should
|
| + |
| + try: |
| + self.run(['git', 'apply', '-'], input=patch) |
| + self.run(['git', 'add', '.']) |
| + output = self.run(['git', 'diff', 'origin/master']) |
| + except ScriptError as error: |
| + print 'Patch caused exception:' |
| + print error |
| + output = '' |
| + |
| + self.clean() |
| + return output |
| def commits_behind_master(self, commit): |
| """Returns the number of commits after the given commit on origin/master. |