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

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

Issue 2690343003: [WPT Export] Fix omitted self in run_command argument (Closed)
Patch Set: Move ChromiumCommit.absolute_chromium_dir assignment up to make tests pass 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 from webkitpy.w3c.chromium_finder import absolute_chromium_dir, absolute_chromiu m_wpt_dir 5 from webkitpy.w3c.chromium_finder import absolute_chromium_dir, absolute_chromiu m_wpt_dir
6 6
7 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/' 7 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/external/wpt/'
8 8
9 9
10 class ChromiumCommit(object): 10 class ChromiumCommit(object):
11 11
12 def __init__(self, host, sha=None, position=None): 12 def __init__(self, host, sha=None, position=None):
13 """ 13 """
14 Args: 14 Args:
15 host: A Host object 15 host: A Host object
16 sha: A Chromium commit SHA 16 sha: A Chromium commit SHA
17 position: A string of the form: 17 position: A string of the form:
18 'Cr-Commit-Position: refs/heads/master@{#431915}' 18 'Cr-Commit-Position: refs/heads/master@{#431915}'
19 or just: 19 or just:
20 'refs/heads/master@{#431915}' 20 'refs/heads/master@{#431915}'
21 """ 21 """
22 self.host = host 22 self.host = host
23 self.absolute_chromium_dir = absolute_chromium_dir(host)
24 self.absolute_chromium_wpt_dir = absolute_chromium_wpt_dir(host)
23 25
24 assert sha or position, 'requires sha or position' 26 assert sha or position, 'requires sha or position'
25 assert not (sha and position), 'cannot accept both sha and position' 27 assert not (sha and position), 'cannot accept both sha and position'
26 28
27 if position and not sha: 29 if position and not sha:
28 if position.startswith('Cr-Commit-Position: '): 30 if position.startswith('Cr-Commit-Position: '):
29 position = position[len('Cr-Commit-Position: '):] 31 position = position[len('Cr-Commit-Position: '):]
30 32
31 sha = self.position_to_sha(position) 33 sha = self.position_to_sha(position)
32 34
33 assert len(sha) == 40, 'Expected SHA-1 hash, got {}'.format(sha) 35 assert len(sha) == 40, 'Expected SHA-1 hash, got {}'.format(sha)
34 self.sha = sha 36 self.sha = sha
35 self.position = position 37 self.position = position
36 38
37 self.absolute_chromium_dir = absolute_chromium_dir(host)
38 self.absolute_chromium_wpt_dir = absolute_chromium_wpt_dir(host)
39
40 def num_behind_master(self): 39 def num_behind_master(self):
41 """Returns the number of commits this commit is behind origin/master. 40 """Returns the number of commits this commit is behind origin/master.
42 It is inclusive of this commit and of the latest commit. 41 It is inclusive of this commit and of the latest commit.
43 """ 42 """
44 return len(self.host.executive.run_command([ 43 return len(self.host.executive.run_command([
45 'git', 'rev-list', '{}..origin/master'.format(self.sha) 44 'git', 'rev-list', '{}..origin/master'.format(self.sha)
46 ], cwd=self.absolute_chromium_dir).splitlines()) 45 ], cwd=self.absolute_chromium_dir).splitlines())
47 46
48 def position_to_sha(self, commit_position): 47 def position_to_sha(self, commit_position):
49 return self.host.executive.run_command([ 48 return self.host.executive.run_command([
50 'git', 'crrev-parse', commit_position 49 'git', 'crrev-parse', commit_position
51 ], cwd=absolute_chromium_dir).strip() 50 ], cwd=self.absolute_chromium_dir).strip()
52 51
53 def subject(self): 52 def subject(self):
54 return self.host.executive.run_command([ 53 return self.host.executive.run_command([
55 'git', 'show', '--format=%s', '--no-patch', self.sha 54 'git', 'show', '--format=%s', '--no-patch', self.sha
56 ], cwd=self.absolute_chromium_dir) 55 ], cwd=self.absolute_chromium_dir)
57 56
58 def body(self): 57 def body(self):
59 return self.host.executive.run_command([ 58 return self.host.executive.run_command([
60 'git', 'show', '--format=%b', '--no-patch', self.sha 59 'git', 'show', '--format=%b', '--no-patch', self.sha
61 ], cwd=absolute_chromium_dir) 60 ], cwd=self.absolute_chromium_dir)
62 61
63 def author(self): 62 def author(self):
64 return self.host.executive.run_command([ 63 return self.host.executive.run_command([
65 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha 64 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha
66 ], cwd=self.absolute_chromium_dir) 65 ], cwd=self.absolute_chromium_dir)
67 66
68 def message(self): 67 def message(self):
69 """Returns a string with a commit's subject and body.""" 68 """Returns a string with a commit's subject and body."""
70 return self.host.executive.run_command([ 69 return self.host.executive.run_command([
71 'git', 'show', '--format=%B', '--no-patch', self.sha 70 'git', 'show', '--format=%B', '--no-patch', self.sha
(...skipping 22 matching lines...) Expand all
94 def format_patch(self): 93 def format_patch(self):
95 """Makes a patch with only exportable changes.""" 94 """Makes a patch with only exportable changes."""
96 filtered_files = self.filtered_changed_files() 95 filtered_files = self.filtered_changed_files()
97 96
98 if not filtered_files: 97 if not filtered_files:
99 return '' 98 return ''
100 99
101 return self.host.executive.run_command([ 100 return self.host.executive.run_command([
102 'git', 'format-patch', '-1', '--stdout', self.sha, '--' 101 'git', 'format-patch', '-1', '--stdout', self.sha, '--'
103 ] + filtered_files, cwd=self.absolute_chromium_dir) 102 ] + filtered_files, cwd=self.absolute_chromium_dir)
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