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

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

Issue 2657523005: WPT Export: trim lines from branch list, stage changes before committing (Closed)
Patch Set: Fix unit test 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 | third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py » ('j') | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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', 'origin/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 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
78 Args: 78 Args:
79 message: Commit message string. 79 message: Commit message string.
80 patch: A patch that can be applied by git apply. 80 patch: A patch that can be applied by git apply.
81 """ 81 """
82 self.clean() 82 self.clean()
83 all_branches = self.all_branches() 83 all_branches = self.all_branches()
84 84
85 if self.branch_name in all_branches: 85 if self.branch_name in all_branches:
86 _log.info('Local branch %s already exists, deleting', self.branch_na me) 86 _log.info('Local branch %s already exists, deleting', self.branch_na me)
87 self.run(['git', 'branch', '-D', self.branch_name]) 87 self.run(['git', 'branch', '-D', self.branch_name])
88 88
89 _log.info('Creating local branch %s', self.branch_name) 89 _log.info('Creating local branch %s', self.branch_name)
90 self.run(['git', 'checkout', '-b', self.branch_name]) 90 self.run(['git', 'checkout', '-b', self.branch_name])
91 91
92 # Remove Chromium WPT directory prefix. 92 # Remove Chromium WPT directory prefix.
93 patch = patch.replace(CHROMIUM_WPT_DIR, '') 93 patch = patch.replace(CHROMIUM_WPT_DIR, '')
94 94
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', 'commit', '--author', author, '-am', message]) 99 self.run(['git', 'commit', '--author', author, '-am', message])
99 self.run(['git', 'push', REMOTE_NAME, self.branch_name]) 100 self.run(['git', 'push', REMOTE_NAME, self.branch_name])
100 101
101 return self.branch_name 102 return self.branch_name
102 103
103 def test_patch(self, patch): 104 def test_patch(self, patch):
104 """Returns the expected output of a patch against origin/master. 105 """Returns the expected output of a patch against origin/master.
105 106
106 Args: 107 Args:
107 patch: The patch to test against. 108 patch: The patch to test against.
(...skipping 19 matching lines...) Expand all
127 128
128 def commits_behind_master(self, commit): 129 def commits_behind_master(self, commit):
129 """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 .
130 131
131 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
132 commit is on the the master branch. 133 commit is on the the master branch.
133 """ 134 """
134 return len(self.run([ 135 return len(self.run([
135 'git', 'rev-list', '{}..origin/master'.format(commit) 136 'git', 'rev-list', '{}..origin/master'.format(commit)
136 ]).splitlines()) 137 ]).splitlines())
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698