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

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

Issue 2703663005: [WPT Export] Use github remote, not origin (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 17 matching lines...) Expand all
28 web-platform-tests repo is already checked out at this path. 28 web-platform-tests repo is already checked out at this path.
29 """ 29 """
30 self.host = host 30 self.host = host
31 self.path = path 31 self.path = path
32 self.branch_name = 'chromium-export-try' 32 self.branch_name = 'chromium-export-try'
33 33
34 def fetch(self): 34 def fetch(self):
35 if self.host.filesystem.exists(self.path): 35 if self.host.filesystem.exists(self.path):
36 _log.info('WPT checkout exists at %s, fetching latest', self.path) 36 _log.info('WPT checkout exists at %s, fetching latest', self.path)
37 self.run(['git', 'fetch', '--all']) 37 self.run(['git', 'fetch', '--all'])
38 self.run(['git', 'checkout', 'origin/master']) 38 self.run(['git', 'checkout', 'github/master'])
39 else: 39 else:
40 _log.info('Cloning %s into %s', WPT_REPO_URL, self.path) 40 _log.info('Cloning %s into %s', WPT_REPO_URL, self.path)
qyearsley 2017/02/17 19:18:41 Question: Would it make sense to change this to us
41 self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self. path]) 41 self.host.executive.run_command(['git', 'clone', WPT_REPO_URL, self. path])
42 42
43 if REMOTE_NAME not in self.run(['git', 'remote']): 43 if REMOTE_NAME not in self.run(['git', 'remote']):
44 self.run(['git', 'remote', 'add', REMOTE_NAME, WPT_SSH_URL]) 44 self.run(['git', 'remote', 'add', REMOTE_NAME, WPT_SSH_URL])
45 45
46 def run(self, command, **kwargs): 46 def run(self, command, **kwargs):
47 """Runs a command in the local WPT directory.""" 47 """Runs a command in the local WPT directory."""
48 return self.host.executive.run_command(command, cwd=self.path, **kwargs) 48 return self.host.executive.run_command(command, cwd=self.path, **kwargs)
49 49
50 def most_recent_chromium_commit(self): 50 def most_recent_chromium_commit(self):
51 """Finds the most recent commit in WPT with a Chromium commit position." "" 51 """Finds the most recent commit in WPT with a Chromium commit position." ""
52 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position']) 52 wpt_commit_hash = self.run(['git', 'rev-list', 'HEAD', '-n', '1', '--gre p=Cr-Commit-Position'])
53 if not wpt_commit_hash: 53 if not wpt_commit_hash:
54 return None, None 54 return None, None
55 55
56 wpt_commit_hash = wpt_commit_hash.strip() 56 wpt_commit_hash = wpt_commit_hash.strip()
57 position = self.run(['git', 'footers', '--position', wpt_commit_hash]) 57 position = self.run(['git', 'footers', '--position', wpt_commit_hash])
58 position = position.strip() 58 position = position.strip()
59 assert position 59 assert position
60 60
61 chromium_commit = ChromiumCommit(self.host, position=position) 61 chromium_commit = ChromiumCommit(self.host, position=position)
62 return wpt_commit_hash, chromium_commit 62 return wpt_commit_hash, chromium_commit
63 63
64 def clean(self): 64 def clean(self):
65 self.run(['git', 'reset', '--hard', 'HEAD']) 65 self.run(['git', 'reset', '--hard', 'HEAD'])
66 self.run(['git', 'clean', '-fdx']) 66 self.run(['git', 'clean', '-fdx'])
67 self.run(['git', 'checkout', 'origin/master']) 67 self.run(['git', 'checkout', 'github/master'])
68 if self.branch_name in self.all_branches(): 68 if self.branch_name in self.all_branches():
69 self.run(['git', 'branch', '-D', self.branch_name]) 69 self.run(['git', 'branch', '-D', self.branch_name])
70 70
71 def all_branches(self): 71 def all_branches(self):
72 """Returns a list of local and remote branches.""" 72 """Returns a list of local and remote branches."""
73 return [s.strip() for s in self.run(['git', 'branch', '-a']).splitlines( )] 73 return [s.strip() for s in self.run(['git', 'branch', '-a']).splitlines( )]
74 74
75 def create_branch_with_patch(self, message, patch, author): 75 def create_branch_with_patch(self, message, patch, author):
76 """Commits the given patch and pushes to the upstream repo. 76 """Commits the given patch and pushes to the upstream repo.
77 77
(...skipping 17 matching lines...) Expand all
95 # TODO(jeffcarp): Use git am -p<n> where n is len(CHROMIUM_WPT_DIR.split (/')) 95 # TODO(jeffcarp): Use git am -p<n> where n is len(CHROMIUM_WPT_DIR.split (/'))
96 # or something not off-by-one. 96 # or something not off-by-one.
97 self.run(['git', 'apply', '-'], input=patch) 97 self.run(['git', 'apply', '-'], input=patch)
98 self.run(['git', 'add', '.']) 98 self.run(['git', 'add', '.'])
99 self.run(['git', 'commit', '--author', author, '-am', message]) 99 self.run(['git', 'commit', '--author', author, '-am', message])
100 self.run(['git', 'push', '-f', REMOTE_NAME, self.branch_name]) 100 self.run(['git', 'push', '-f', REMOTE_NAME, self.branch_name])
101 101
102 return self.branch_name 102 return self.branch_name
103 103
104 def test_patch(self, patch, chromium_commit=None): 104 def test_patch(self, patch, chromium_commit=None):
105 """Returns the expected output of a patch against origin/master. 105 """Returns the expected output of a patch against github/master.
106 106
107 Args: 107 Args:
108 patch: The patch to test against. 108 patch: The patch to test against.
109 109
110 Returns: 110 Returns:
111 A string containing the diff the patch produced. 111 A string containing the diff the patch produced.
112 """ 112 """
113 self.clean() 113 self.clean()
114 114
115 # Remove Chromium WPT directory prefix. 115 # Remove Chromium WPT directory prefix.
116 patch = patch.replace(CHROMIUM_WPT_DIR, '') 116 patch = patch.replace(CHROMIUM_WPT_DIR, '')
117 117
118 try: 118 try:
119 self.run(['git', 'apply', '-'], input=patch) 119 self.run(['git', 'apply', '-'], input=patch)
120 self.run(['git', 'add', '.']) 120 self.run(['git', 'add', '.'])
121 output = self.run(['git', 'diff', 'origin/master']) 121 output = self.run(['git', 'diff', 'github/master'])
122 except ScriptError: 122 except ScriptError:
123 _log.warning('Patch did not apply cleanly, skipping.') 123 _log.warning('Patch did not apply cleanly, skipping.')
124 if chromium_commit: 124 if chromium_commit:
125 _log.warning('Commit details:\n%s\n%s', chromium_commit.sha, 125 _log.warning('Commit details:\n%s\n%s', chromium_commit.sha,
126 chromium_commit.subject()) 126 chromium_commit.subject())
127 output = '' 127 output = ''
128 128
129 self.clean() 129 self.clean()
130 return output 130 return output
131 131
132 def commits_behind_master(self, commit): 132 def commits_behind_master(self, commit):
133 """Returns the number of commits after the given commit on origin/master . 133 """Returns the number of commits after the given commit on github/master .
134 134
135 This doesn't include the given commit, and this assumes that the given 135 This doesn't include the given commit, and this assumes that the given
136 commit is on the the master branch. 136 commit is on the the master branch.
137 """ 137 """
138 return len(self.run([ 138 return len(self.run([
139 'git', 'rev-list', '{}..origin/master'.format(commit) 139 'git', 'rev-list', '{}..github/master'.format(commit)
140 ]).splitlines()) 140 ]).splitlines())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698