Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from recipe_engine import recipe_api | |
| 6 | |
| 7 | |
| 8 class FinditApi(recipe_api.RecipeApi): | |
| 9 | |
| 10 def _calculate_repo_dir(self, solution_name): | |
| 11 """Returns the relative path of the solution checkout to the root one.""" | |
| 12 if solution_name == 'src': | |
| 13 return '' | |
| 14 else: | |
| 15 root_solution_name = 'src/' | |
| 16 assert solution_name.startswith(root_solution_name) | |
| 17 return solution_name[len(root_solution_name):] | |
| 18 | |
| 19 def get_files_affected_by_revision(self, revision, solution_name): | |
| 20 """Returns the files changed by the given revision. | |
|
Dirk Pranke
2015/11/24 00:17:41
I would probably call this routine "files_changed_
stgao
2015/11/24 23:19:19
Done.
| |
| 21 | |
| 22 Args: | |
| 23 revision (str): the git hash of a commit. | |
| 24 solution_name (str): the gclient solution name, eg: | |
| 25 "src" for chromium, "src/third_party/pdfium" for pdfium. | |
| 26 """ | |
| 27 solution_name = solution_name.replace('\\', '/') | |
| 28 repo_dir = self._calculate_repo_dir(solution_name) | |
| 29 cwd = self.m.path['checkout'].join(repo_dir) | |
| 30 | |
| 31 previous_revision = '%s~1' % revision | |
| 32 step_result = self.m.git('diff', revision + '~1', revision, '--name-only', | |
| 33 name='git diff to analyze commit', | |
| 34 stdout=self.m.raw_io.output(), | |
| 35 cwd=cwd, | |
| 36 step_test_data=lambda: | |
| 37 self.m.raw_io.test_api.stream_output('foo.cc')) | |
| 38 | |
| 39 paths = step_result.stdout.split() | |
| 40 if repo_dir: | |
| 41 paths = [self.m.path.join(repo_dir, path) for path in paths] | |
| 42 if self.m.platform.is_win: | |
| 43 # Looks like "analyze" wants POSIX slashes even on Windows (since git | |
| 44 # uses that format even on Windows). | |
| 45 paths = [path.replace('\\', '/') for path in paths] | |
| 46 | |
| 47 step_result.presentation.logs['files'] = paths | |
| 48 return paths | |
| OLD | NEW |