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

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

Issue 2692233002: [WPT Export] Fix cwd on run_command calls in ChromiumCommit (Closed)
Patch Set: Strictly assert that SHA-1 hash was passed to ChromiumCommit 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
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 from webkitpy.common.memoized import memoized 5 from webkitpy.common.memoized import memoized
6 from webkitpy.common.webkit_finder import WebKitFinder 6 from webkitpy.common.webkit_finder import WebKitFinder
7 7
8 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/' 8 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/'
9 9
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 assert sha or position, 'requires sha or position' 25 assert sha or position, 'requires sha or position'
26 assert not (sha and position), 'cannot accept both sha and position' 26 assert not (sha and position), 'cannot accept both sha and position'
27 27
28 if position and not sha: 28 if position and not sha:
29 if position.startswith('Cr-Commit-Position: '): 29 if position.startswith('Cr-Commit-Position: '):
30 position = position[len('Cr-Commit-Position: '):] 30 position = position[len('Cr-Commit-Position: '):]
31 31
32 sha = self.position_to_sha(position) 32 sha = self.position_to_sha(position)
33 33
34 assert len(sha) == 40, 'Expected SHA-1 hash, got {}'.format(sha)
34 self.sha = sha 35 self.sha = sha
35 self.position = position 36 self.position = position
36 37
37 def num_behind_master(self): 38 def num_behind_master(self):
38 """Returns the number of commits this commit is behind origin/master. 39 """Returns the number of commits this commit is behind origin/master.
39 It is inclusive of this commit and of the latest commit. 40 It is inclusive of this commit and of the latest commit.
40 """ 41 """
41 return len(self.host.executive.run_command([ 42 return len(self.host.executive.run_command([
42 'git', 'rev-list', '{}..origin/master'.format(self.sha) 43 'git', 'rev-list', '{}..origin/master'.format(self.sha)
43 ]).splitlines()) 44 ], cwd=self.absolute_chromium_dir()).splitlines())
44 45
45 def position_to_sha(self, commit_position): 46 def position_to_sha(self, commit_position):
46 return self.host.executive.run_command([ 47 return self.host.executive.run_command([
47 'git', 'crrev-parse', commit_position 48 'git', 'crrev-parse', commit_position
48 ]).strip() 49 ], cwd=self.absolute_chromium_dir()).strip()
49 50
50 def subject(self): 51 def subject(self):
51 return self.host.executive.run_command([ 52 return self.host.executive.run_command([
52 'git', 'show', '--format=%s', '--no-patch', self.sha 53 'git', 'show', '--format=%s', '--no-patch', self.sha
53 ]) 54 ], cwd=self.absolute_chromium_dir())
54 55
55 def body(self): 56 def body(self):
56 return self.host.executive.run_command([ 57 return self.host.executive.run_command([
57 'git', 'show', '--format=%b', '--no-patch', self.sha 58 'git', 'show', '--format=%b', '--no-patch', self.sha
58 ]) 59 ], cwd=self.absolute_chromium_dir())
59 60
60 def author(self): 61 def author(self):
61 return self.host.executive.run_command([ 62 return self.host.executive.run_command([
62 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha 63 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha
63 ]) 64 ], cwd=self.absolute_chromium_dir())
64 65
65 def message(self): 66 def message(self):
66 """Returns a string with a commit's subject and body.""" 67 """Returns a string with a commit's subject and body."""
67 return self.host.executive.run_command([ 68 return self.host.executive.run_command([
68 'git', 'show', '--format=%B', '--no-patch', self.sha 69 'git', 'show', '--format=%B', '--no-patch', self.sha
69 ]) 70 ], cwd=self.absolute_chromium_dir())
70 71
71 def filtered_changed_files(self): 72 def filtered_changed_files(self):
72 """Makes a patch with just changes in files in the WPT dir for a given c ommit.""" 73 """Makes a patch with just changes in files in the WPT dir for a given c ommit."""
73 changed_files = self.host.executive.run_command([ 74 changed_files = self.host.executive.run_command([
74 'git', 'diff-tree', '--name-only', '--no-commit-id', '-r', self.sha, 75 'git', 'diff-tree', '--name-only', '--no-commit-id', '-r', self.sha,
75 '--', self.absolute_chromium_wpt_dir() 76 '--', self.absolute_chromium_wpt_dir()
76 ]).splitlines() 77 ], cwd=self.absolute_chromium_dir()).splitlines()
77 78
78 blacklist = [ 79 blacklist = [
79 'MANIFEST.json', 80 'MANIFEST.json',
80 self.host.filesystem.join('resources', 'testharnessreport.js'), 81 self.host.filesystem.join('resources', 'testharnessreport.js'),
81 ] 82 ]
82 qualified_blacklist = [CHROMIUM_WPT_DIR + f for f in blacklist] 83 qualified_blacklist = [CHROMIUM_WPT_DIR + f for f in blacklist]
83 84
84 return [f for f in changed_files if f not in qualified_blacklist and not self.is_baseline(f)] 85 return [f for f in changed_files if f not in qualified_blacklist and not self.is_baseline(f)]
85 86
86 @staticmethod 87 @staticmethod
(...skipping 14 matching lines...) Expand all
101 102
102 @memoized 103 @memoized
103 def absolute_chromium_wpt_dir(self): 104 def absolute_chromium_wpt_dir(self):
104 finder = WebKitFinder(self.host.filesystem) 105 finder = WebKitFinder(self.host.filesystem)
105 return finder.path_from_webkit_base('LayoutTests', 'external', 'wpt') 106 return finder.path_from_webkit_base('LayoutTests', 'external', 'wpt')
106 107
107 @memoized 108 @memoized
108 def absolute_chromium_dir(self): 109 def absolute_chromium_dir(self):
109 finder = WebKitFinder(self.host.filesystem) 110 finder = WebKitFinder(self.host.filesystem)
110 return finder.chromium_base() 111 return finder.chromium_base()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698