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 get_files_affected_by_revision(self, revision, repo_dir=''): | |
| 11 """Returns the files changed by the given revision. | |
| 12 | |
| 13 Args: | |
| 14 revision (str): the git hash of a commit. | |
| 15 repo_dir (str): the relative path to the checkout directory. | |
| 16 """ | |
| 17 if repo_dir: | |
| 18 cwd = self.m.path['checkout'] | |
| 19 else: | |
| 20 cwd = self.m.path['checkout'].join(repo_dir) | |
|
iannucci
2015/11/18 03:57:53
is this if/else backwards?
Does it make sense to
stgao
2015/11/19 22:06:33
Changed input parameter to "solution_name" and der
| |
| 21 | |
| 22 previous_revision = '%s~1' % revision | |
| 23 step_result = self.m.git('diff', previous_revision, revision, '--name-only', | |
|
iannucci
2015/11/18 03:57:54
I think
revision+"~1"
is possibly clearer and
stgao
2015/11/19 22:06:33
Done.
| |
| 24 name='git diff to analyze commit', | |
| 25 stdout=self.m.raw_io.output(), | |
| 26 cwd=cwd, | |
| 27 step_test_data=lambda: | |
| 28 self.m.raw_io.test_api.stream_output('foo.cc')) | |
| 29 | |
| 30 paths = step_result.stdout.split() | |
| 31 if repo_dir: | |
| 32 paths = [self.m.path.join(repo_dir, path) for path in paths] | |
| 33 if self.m.platform.is_win: | |
| 34 # Looks like "analyze" wants POSIX slashes even on Windows (since git | |
| 35 # uses that format even on Windows). | |
| 36 paths = [path.replace('\\', '/') for path in paths] | |
| 37 | |
| 38 step_result.presentation.logs['files'] = paths | |
| 39 return paths | |
| OLD | NEW |