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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py

Issue 2719173002: [WPT Export] Require GitHub API token in WPT remote origin URL (Closed)
Patch Set: Remove --depth, make LocalWPT.gh_token optional Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
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 """A utility class for interacting with a local checkout of the Web Platform Tes ts.""" 5 """A utility class for interacting with a local checkout of the Web Platform Tes ts."""
6 6
7 import logging 7 import logging
8 8
9 from webkitpy.common.system.executive import ScriptError 9 from webkitpy.common.system.executive import ScriptError
10 from webkitpy.w3c.chromium_commit import ChromiumCommit 10 from webkitpy.w3c.chromium_commit import ChromiumCommit
11 from webkitpy.w3c.common import WPT_GH_REPO_URL, CHROMIUM_WPT_DIR 11 from webkitpy.w3c.common import WPT_GH_REPO_URL_TEMPLATE, CHROMIUM_WPT_DIR
12 12
13 13
14 _log = logging.getLogger(__name__) 14 _log = logging.getLogger(__name__)
15 15
16 16
17 class LocalWPT(object): 17 class LocalWPT(object):
18 18
19 def __init__(self, host, path='/tmp/wpt'): 19 def __init__(self, host, gh_token=None, path='/tmp/wpt'):
20 """ 20 """
21 Args: 21 Args:
22 host: A Host object. 22 host: A Host object.
23 path: Optional, the path to the web-platform-tests repo. 23 path: Optional, the path to the web-platform-tests repo.
24 If this directory already exists, it is assumed that the 24 If this directory already exists, it is assumed that the
25 web-platform-tests repo is already checked out at this path. 25 web-platform-tests repo is already checked out at this path.
26 """ 26 """
27 self.host = host 27 self.host = host
28 self.path = path 28 self.path = path
29 self.gh_token = gh_token
29 self.branch_name = 'chromium-export-try' 30 self.branch_name = 'chromium-export-try'
30 31
31 def fetch(self): 32 def fetch(self):
33 assert self.gh_token, 'LocalWPT.gh_token required for fetch'
32 if self.host.filesystem.exists(self.path): 34 if self.host.filesystem.exists(self.path):
33 _log.info('WPT checkout exists at %s, fetching latest', self.path) 35 _log.info('WPT checkout exists at %s, fetching latest', self.path)
34 self.run(['git', 'fetch', 'origin']) 36 self.run(['git', 'fetch', 'origin'])
35 self.run(['git', 'checkout', 'origin/master']) 37 self.run(['git', 'checkout', 'origin/master'])
36 else: 38 else:
37 _log.info('Cloning %s into %s', WPT_GH_REPO_URL, self.path) 39 _log.info('Cloning GitHub w3c/web-platform-tests into %s', self.path )
38 self.host.executive.run_command(['git', 'clone', WPT_GH_REPO_URL, se lf.path]) 40 remote_url = WPT_GH_REPO_URL_TEMPLATE.format(self.gh_token)
41 self.host.executive.run_command(['git', 'clone', remote_url, self.pa th])
39 42
40 def run(self, command, **kwargs): 43 def run(self, command, **kwargs):
41 """Runs a command in the local WPT directory.""" 44 """Runs a command in the local WPT directory."""
42 return self.host.executive.run_command(command, cwd=self.path, **kwargs) 45 return self.host.executive.run_command(command, cwd=self.path, **kwargs)
43 46
44 def most_recent_chromium_commit(self): 47 def most_recent_chromium_commit(self):
45 """Finds the most recent commit in WPT with a Chromium commit position." "" 48 """Finds the most recent commit in WPT with a Chromium commit position." ""
46 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position']) 49 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position'])
47 if not wpt_commit_hash: 50 if not wpt_commit_hash:
48 return None, None 51 return None, None
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 128
126 def commits_behind_master(self, commit): 129 def commits_behind_master(self, commit):
127 """Returns the number of commits after the given commit on origin/master . 130 """Returns the number of commits after the given commit on origin/master .
128 131
129 This doesn't include the given commit, and this assumes that the given 132 This doesn't include the given commit, and this assumes that the given
130 commit is on the the master branch. 133 commit is on the the master branch.
131 """ 134 """
132 return len(self.run([ 135 return len(self.run([
133 'git', 'rev-list', '{}..origin/master'.format(commit) 136 'git', 'rev-list', '{}..origin/master'.format(commit)
134 ]).splitlines()) 137 ]).splitlines())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698