Chromium Code Reviews| OLD | NEW |
|---|---|
| 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): |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 if position.startswith('Cr-Commit-Position: '): | 28 if position.startswith('Cr-Commit-Position: '): |
| 29 position = position[len('Cr-Commit-Position: '):] | 29 position = position[len('Cr-Commit-Position: '):] |
| 30 | 30 |
| 31 sha = self.position_to_sha(position) | 31 sha = self.position_to_sha(position) |
| 32 | 32 |
| 33 assert len(sha) == 40, 'Expected SHA-1 hash, got {}'.format(sha) | 33 assert len(sha) == 40, 'Expected SHA-1 hash, got {}'.format(sha) |
| 34 self.sha = sha | 34 self.sha = sha |
| 35 self.position = position | 35 self.position = position |
| 36 | 36 |
| 37 self.absolute_chromium_dir = absolute_chromium_dir(host) | 37 self.absolute_chromium_dir = absolute_chromium_dir(host) |
| 38 self.absolute_chromium_wpt_dir = absolute_chromium_wpt_dir(host) | 38 self.absolute_chromium_wpt_dir = absolute_chromium_wpt_dir(host) |
|
qyearsley
2017/02/14 23:45:32
Didn't mention it before, but these could also opt
| |
| 39 | 39 |
| 40 def num_behind_master(self): | 40 def num_behind_master(self): |
| 41 """Returns the number of commits this commit is behind origin/master. | 41 """Returns the number of commits this commit is behind origin/master. |
| 42 It is inclusive of this commit and of the latest commit. | 42 It is inclusive of this commit and of the latest commit. |
| 43 """ | 43 """ |
| 44 return len(self.host.executive.run_command([ | 44 return len(self.host.executive.run_command([ |
| 45 'git', 'rev-list', '{}..origin/master'.format(self.sha) | 45 'git', 'rev-list', '{}..origin/master'.format(self.sha) |
| 46 ], cwd=self.absolute_chromium_dir).splitlines()) | 46 ], cwd=self.absolute_chromium_dir).splitlines()) |
| 47 | 47 |
| 48 def position_to_sha(self, commit_position): | 48 def position_to_sha(self, commit_position): |
| 49 return self.host.executive.run_command([ | 49 return self.host.executive.run_command([ |
| 50 'git', 'crrev-parse', commit_position | 50 'git', 'crrev-parse', commit_position |
| 51 ], cwd=absolute_chromium_dir).strip() | 51 ], cwd=self.absolute_chromium_dir).strip() |
| 52 | 52 |
| 53 def subject(self): | 53 def subject(self): |
| 54 return self.host.executive.run_command([ | 54 return self.host.executive.run_command([ |
| 55 'git', 'show', '--format=%s', '--no-patch', self.sha | 55 'git', 'show', '--format=%s', '--no-patch', self.sha |
| 56 ], cwd=self.absolute_chromium_dir) | 56 ], cwd=self.absolute_chromium_dir) |
| 57 | 57 |
| 58 def body(self): | 58 def body(self): |
| 59 return self.host.executive.run_command([ | 59 return self.host.executive.run_command([ |
| 60 'git', 'show', '--format=%b', '--no-patch', self.sha | 60 'git', 'show', '--format=%b', '--no-patch', self.sha |
| 61 ], cwd=absolute_chromium_dir) | 61 ], cwd=self.absolute_chromium_dir) |
| 62 | 62 |
| 63 def author(self): | 63 def author(self): |
| 64 return self.host.executive.run_command([ | 64 return self.host.executive.run_command([ |
| 65 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha | 65 'git', 'show', '--format="%aN <%aE>"', '--no-patch', self.sha |
| 66 ], cwd=self.absolute_chromium_dir) | 66 ], cwd=self.absolute_chromium_dir) |
| 67 | 67 |
| 68 def message(self): | 68 def message(self): |
| 69 """Returns a string with a commit's subject and body.""" | 69 """Returns a string with a commit's subject and body.""" |
| 70 return self.host.executive.run_command([ | 70 return self.host.executive.run_command([ |
| 71 'git', 'show', '--format=%B', '--no-patch', self.sha | 71 'git', 'show', '--format=%B', '--no-patch', self.sha |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 94 def format_patch(self): | 94 def format_patch(self): |
| 95 """Makes a patch with only exportable changes.""" | 95 """Makes a patch with only exportable changes.""" |
| 96 filtered_files = self.filtered_changed_files() | 96 filtered_files = self.filtered_changed_files() |
| 97 | 97 |
| 98 if not filtered_files: | 98 if not filtered_files: |
| 99 return '' | 99 return '' |
| 100 | 100 |
| 101 return self.host.executive.run_command([ | 101 return self.host.executive.run_command([ |
| 102 'git', 'format-patch', '-1', '--stdout', self.sha, '--' | 102 'git', 'format-patch', '-1', '--stdout', self.sha, '--' |
| 103 ] + filtered_files, cwd=self.absolute_chromium_dir) | 103 ] + filtered_files, cwd=self.absolute_chromium_dir) |
| OLD | NEW |